mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Merge pull request #29022 from mprobst/no-resolve-libref
Do not process library reference directives with noLib set.
This commit is contained in:
@@ -2227,8 +2227,9 @@ namespace ts {
|
||||
processReferencedFiles(file, isDefaultLib);
|
||||
processTypeReferenceDirectives(file);
|
||||
}
|
||||
|
||||
processLibReferenceDirectives(file);
|
||||
if (!options.noLib) {
|
||||
processLibReferenceDirectives(file);
|
||||
}
|
||||
|
||||
modulesWithElidedImports.set(file.path, false);
|
||||
processImportedModules(file);
|
||||
@@ -2315,8 +2316,10 @@ namespace ts {
|
||||
processReferencedFiles(file, isDefaultLib);
|
||||
processTypeReferenceDirectives(file);
|
||||
}
|
||||
if (!options.noLib) {
|
||||
processLibReferenceDirectives(file);
|
||||
}
|
||||
|
||||
processLibReferenceDirectives(file);
|
||||
|
||||
// always process imported modules to record module name resolutions
|
||||
processImportedModules(file);
|
||||
|
||||
51
tests/baselines/reference/libReferenceNoLib.js
Normal file
51
tests/baselines/reference/libReferenceNoLib.js
Normal file
@@ -0,0 +1,51 @@
|
||||
//// [tests/cases/conformance/declarationEmit/libReferenceNoLib.ts] ////
|
||||
|
||||
//// [fakelib.ts]
|
||||
// Test that passing noLib disables <reference lib> resolution.
|
||||
|
||||
interface Object { }
|
||||
interface Array<T> { }
|
||||
interface String { }
|
||||
interface Boolean { }
|
||||
interface Number { }
|
||||
interface Function { }
|
||||
interface RegExp { }
|
||||
interface IArguments { }
|
||||
|
||||
|
||||
//// [file1.ts]
|
||||
/// <reference lib="dom" />
|
||||
export declare interface HTMLElement { field: string; }
|
||||
export const elem: HTMLElement = { field: 'a' };
|
||||
|
||||
|
||||
//// [fakelib.js]
|
||||
// Test that passing noLib disables <reference lib> resolution.
|
||||
//// [file1.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.elem = { field: 'a' };
|
||||
|
||||
|
||||
//// [fakelib.d.ts]
|
||||
interface Object {
|
||||
}
|
||||
interface Array<T> {
|
||||
}
|
||||
interface String {
|
||||
}
|
||||
interface Boolean {
|
||||
}
|
||||
interface Number {
|
||||
}
|
||||
interface Function {
|
||||
}
|
||||
interface RegExp {
|
||||
}
|
||||
interface IArguments {
|
||||
}
|
||||
//// [file1.d.ts]
|
||||
export declare interface HTMLElement {
|
||||
field: string;
|
||||
}
|
||||
export declare const elem: HTMLElement;
|
||||
40
tests/baselines/reference/libReferenceNoLib.symbols
Normal file
40
tests/baselines/reference/libReferenceNoLib.symbols
Normal file
@@ -0,0 +1,40 @@
|
||||
=== tests/cases/conformance/declarationEmit/fakelib.ts ===
|
||||
// Test that passing noLib disables <reference lib> resolution.
|
||||
|
||||
interface Object { }
|
||||
>Object : Symbol(Object, Decl(fakelib.ts, 0, 0))
|
||||
|
||||
interface Array<T> { }
|
||||
>Array : Symbol(Array, Decl(fakelib.ts, 2, 20))
|
||||
>T : Symbol(T, Decl(fakelib.ts, 3, 16))
|
||||
|
||||
interface String { }
|
||||
>String : Symbol(String, Decl(fakelib.ts, 3, 22))
|
||||
|
||||
interface Boolean { }
|
||||
>Boolean : Symbol(Boolean, Decl(fakelib.ts, 4, 20))
|
||||
|
||||
interface Number { }
|
||||
>Number : Symbol(Number, Decl(fakelib.ts, 5, 21))
|
||||
|
||||
interface Function { }
|
||||
>Function : Symbol(Function, Decl(fakelib.ts, 6, 20))
|
||||
|
||||
interface RegExp { }
|
||||
>RegExp : Symbol(RegExp, Decl(fakelib.ts, 7, 22))
|
||||
|
||||
interface IArguments { }
|
||||
>IArguments : Symbol(IArguments, Decl(fakelib.ts, 8, 20))
|
||||
|
||||
|
||||
=== tests/cases/conformance/declarationEmit/file1.ts ===
|
||||
/// <reference lib="dom" />
|
||||
export declare interface HTMLElement { field: string; }
|
||||
>HTMLElement : Symbol(HTMLElement, Decl(file1.ts, 0, 0))
|
||||
>field : Symbol(HTMLElement.field, Decl(file1.ts, 1, 38))
|
||||
|
||||
export const elem: HTMLElement = { field: 'a' };
|
||||
>elem : Symbol(elem, Decl(file1.ts, 2, 12))
|
||||
>HTMLElement : Symbol(HTMLElement, Decl(file1.ts, 0, 0))
|
||||
>field : Symbol(field, Decl(file1.ts, 2, 34))
|
||||
|
||||
24
tests/baselines/reference/libReferenceNoLib.types
Normal file
24
tests/baselines/reference/libReferenceNoLib.types
Normal file
@@ -0,0 +1,24 @@
|
||||
=== tests/cases/conformance/declarationEmit/fakelib.ts ===
|
||||
// Test that passing noLib disables <reference lib> resolution.
|
||||
No type information for this code.
|
||||
No type information for this code.interface Object { }
|
||||
No type information for this code.interface Array<T> { }
|
||||
No type information for this code.interface String { }
|
||||
No type information for this code.interface Boolean { }
|
||||
No type information for this code.interface Number { }
|
||||
No type information for this code.interface Function { }
|
||||
No type information for this code.interface RegExp { }
|
||||
No type information for this code.interface IArguments { }
|
||||
No type information for this code.
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/declarationEmit/file1.ts ===
|
||||
/// <reference lib="dom" />
|
||||
export declare interface HTMLElement { field: string; }
|
||||
>field : string
|
||||
|
||||
export const elem: HTMLElement = { field: 'a' };
|
||||
>elem : HTMLElement
|
||||
>{ field: 'a' } : { field: string; }
|
||||
>field : string
|
||||
>'a' : "a"
|
||||
|
||||
53
tests/baselines/reference/libReferenceNoLibBundle.js
Normal file
53
tests/baselines/reference/libReferenceNoLibBundle.js
Normal file
@@ -0,0 +1,53 @@
|
||||
//// [tests/cases/conformance/declarationEmit/libReferenceNoLibBundle.ts] ////
|
||||
|
||||
//// [fakelib.ts]
|
||||
// Test that passing noLib disables <reference lib> resolution.
|
||||
|
||||
interface Object { }
|
||||
interface Array<T> { }
|
||||
interface String { }
|
||||
interface Boolean { }
|
||||
interface Number { }
|
||||
interface Function { }
|
||||
interface RegExp { }
|
||||
interface IArguments { }
|
||||
|
||||
|
||||
//// [file1.ts]
|
||||
/// <reference lib="dom" />
|
||||
export declare interface HTMLElement { field: string; }
|
||||
export const elem: HTMLElement = { field: 'a' };
|
||||
|
||||
|
||||
//// [bundle.js]
|
||||
// Test that passing noLib disables <reference lib> resolution.
|
||||
define("file1", ["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.elem = { field: 'a' };
|
||||
});
|
||||
|
||||
|
||||
//// [bundle.d.ts]
|
||||
interface Object {
|
||||
}
|
||||
interface Array<T> {
|
||||
}
|
||||
interface String {
|
||||
}
|
||||
interface Boolean {
|
||||
}
|
||||
interface Number {
|
||||
}
|
||||
interface Function {
|
||||
}
|
||||
interface RegExp {
|
||||
}
|
||||
interface IArguments {
|
||||
}
|
||||
declare module "file1" {
|
||||
export interface HTMLElement {
|
||||
field: string;
|
||||
}
|
||||
export const elem: HTMLElement;
|
||||
}
|
||||
40
tests/baselines/reference/libReferenceNoLibBundle.symbols
Normal file
40
tests/baselines/reference/libReferenceNoLibBundle.symbols
Normal file
@@ -0,0 +1,40 @@
|
||||
=== tests/cases/conformance/declarationEmit/fakelib.ts ===
|
||||
// Test that passing noLib disables <reference lib> resolution.
|
||||
|
||||
interface Object { }
|
||||
>Object : Symbol(Object, Decl(fakelib.ts, 0, 0))
|
||||
|
||||
interface Array<T> { }
|
||||
>Array : Symbol(Array, Decl(fakelib.ts, 2, 20))
|
||||
>T : Symbol(T, Decl(fakelib.ts, 3, 16))
|
||||
|
||||
interface String { }
|
||||
>String : Symbol(String, Decl(fakelib.ts, 3, 22))
|
||||
|
||||
interface Boolean { }
|
||||
>Boolean : Symbol(Boolean, Decl(fakelib.ts, 4, 20))
|
||||
|
||||
interface Number { }
|
||||
>Number : Symbol(Number, Decl(fakelib.ts, 5, 21))
|
||||
|
||||
interface Function { }
|
||||
>Function : Symbol(Function, Decl(fakelib.ts, 6, 20))
|
||||
|
||||
interface RegExp { }
|
||||
>RegExp : Symbol(RegExp, Decl(fakelib.ts, 7, 22))
|
||||
|
||||
interface IArguments { }
|
||||
>IArguments : Symbol(IArguments, Decl(fakelib.ts, 8, 20))
|
||||
|
||||
|
||||
=== tests/cases/conformance/declarationEmit/file1.ts ===
|
||||
/// <reference lib="dom" />
|
||||
export declare interface HTMLElement { field: string; }
|
||||
>HTMLElement : Symbol(HTMLElement, Decl(file1.ts, 0, 0))
|
||||
>field : Symbol(HTMLElement.field, Decl(file1.ts, 1, 38))
|
||||
|
||||
export const elem: HTMLElement = { field: 'a' };
|
||||
>elem : Symbol(elem, Decl(file1.ts, 2, 12))
|
||||
>HTMLElement : Symbol(HTMLElement, Decl(file1.ts, 0, 0))
|
||||
>field : Symbol(field, Decl(file1.ts, 2, 34))
|
||||
|
||||
24
tests/baselines/reference/libReferenceNoLibBundle.types
Normal file
24
tests/baselines/reference/libReferenceNoLibBundle.types
Normal file
@@ -0,0 +1,24 @@
|
||||
=== tests/cases/conformance/declarationEmit/fakelib.ts ===
|
||||
// Test that passing noLib disables <reference lib> resolution.
|
||||
No type information for this code.
|
||||
No type information for this code.interface Object { }
|
||||
No type information for this code.interface Array<T> { }
|
||||
No type information for this code.interface String { }
|
||||
No type information for this code.interface Boolean { }
|
||||
No type information for this code.interface Number { }
|
||||
No type information for this code.interface Function { }
|
||||
No type information for this code.interface RegExp { }
|
||||
No type information for this code.interface IArguments { }
|
||||
No type information for this code.
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/declarationEmit/file1.ts ===
|
||||
/// <reference lib="dom" />
|
||||
export declare interface HTMLElement { field: string; }
|
||||
>field : string
|
||||
|
||||
export const elem: HTMLElement = { field: 'a' };
|
||||
>elem : HTMLElement
|
||||
>{ field: 'a' } : { field: string; }
|
||||
>field : string
|
||||
>'a' : "a"
|
||||
|
||||
21
tests/cases/conformance/declarationEmit/libReferenceNoLib.ts
Normal file
21
tests/cases/conformance/declarationEmit/libReferenceNoLib.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
// @target: esnext
|
||||
// @module: commonjs
|
||||
// @noLib: true
|
||||
// @declaration: true
|
||||
// Test that passing noLib disables <reference lib> resolution.
|
||||
|
||||
// @filename: fakelib.ts
|
||||
interface Object { }
|
||||
interface Array<T> { }
|
||||
interface String { }
|
||||
interface Boolean { }
|
||||
interface Number { }
|
||||
interface Function { }
|
||||
interface RegExp { }
|
||||
interface IArguments { }
|
||||
|
||||
|
||||
// @filename: file1.ts
|
||||
/// <reference lib="dom" />
|
||||
export declare interface HTMLElement { field: string; }
|
||||
export const elem: HTMLElement = { field: 'a' };
|
||||
@@ -0,0 +1,23 @@
|
||||
// @target: esnext
|
||||
// @module: amd
|
||||
// @noLib: true
|
||||
// @declaration: true
|
||||
// @outFile: bundle.js
|
||||
|
||||
// Test that passing noLib disables <reference lib> resolution.
|
||||
|
||||
// @filename: fakelib.ts
|
||||
interface Object { }
|
||||
interface Array<T> { }
|
||||
interface String { }
|
||||
interface Boolean { }
|
||||
interface Number { }
|
||||
interface Function { }
|
||||
interface RegExp { }
|
||||
interface IArguments { }
|
||||
|
||||
|
||||
// @filename: file1.ts
|
||||
/// <reference lib="dom" />
|
||||
export declare interface HTMLElement { field: string; }
|
||||
export const elem: HTMLElement = { field: 'a' };
|
||||
Reference in New Issue
Block a user