mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-14 19:16:17 -06:00
Merge release-2.1 into master (#12157)
* Update LKG
* Update version
* Update LKG
* Skip overloads with too-short function parameters
If the parameter of an overload is a function and the argument is also a
function, skip the overload if the parameter has fewer arguments than
the argument does. That overload cannot possibly apply, and should not
participate in, for example, contextual typing.
Example:
```ts
interface I {
(a: number): void;
(b: string, c): void;
}
declare function f(i: I): void;
f((x, y) => {});
```
This code now skips the first overload instead of considering.
This was a longstanding bug but was only uncovered now that more
functions expressions are context sensitive.
* Test skip overloads w/too-short function params
1. Update changed baseline.
2. Add a new test with baseline.
* Minor style improvements
* Ignore optionality when skipping overloads
* Do not use contextual signatures with too few parameters
* isAritySmaller runs later: getNonGenericSignature
* rewrite void-returning statements in constructors that capture result of super call (#11868)
* rewrite void-returning statements in constructors that capture result of super call
* linter
* Update LKG
* Fix emit inferred type which is a generic type-alias both fully and partially fill type parameters
* Add tests and baselines
* Skip trying to use alias if there is target type
* Update baselines
* Add diagnostics to remind adding tsconfig file for certain external project (#11932)
* Add diagnostics for certain external project
* Show tsconfig suggestion
* fix lint error
* Address pr
* fix comment
* Update error message
* Flag for not overwrite js files by default without generating errors (#11980)
* WIP
* Properly naming things
* refactor
* apply the option to all files and check out options
* Fix typo
* Update LKG
* lockLinter
* use local registry to check if typings package exist (#12014) (#12032)
use local registry to check if typings package exist
* Add test for https://github.com/Microsoft/TypeScript/pull/11980 (#12027)
* add test for the fix for overwrite emitting error
* cr feedback
* enable sending telemetry events to tsserver client (#12034) (#12051)
enable sending telemetry events
* Update LKG
* Reuse subtree transform flags for incrementally parsed nodes (#12088)
* Update LKG
* Update version
* Update LKG
* Do not emit "use strict" when targeting es6 or higher or module kind is es2015 and the file is external module
* Add tests and baselines
* [Release 2.1] fix11754 global augmentation (#12133)
* Exclude global augmentation from module resolution logic
* Address PR: check using string literal instead of NodeFlags.globalAugmentation
* Remove comment
This commit is contained in:
parent
4dc58dde38
commit
d537b79c61
@ -11493,7 +11493,7 @@ namespace ts {
|
||||
function checkJsxOpeningLikeElement(node: JsxOpeningLikeElement) {
|
||||
checkGrammarJsxElement(node);
|
||||
checkJsxPreconditions(node);
|
||||
// The reactNamespace/jsxFactory's root symbol should be marked as 'used' so we don't incorrectly elide its import.
|
||||
// The reactNamespace/jsxFactory's root symbol should be marked as 'used' so we don't incorrectly elide its import.
|
||||
// And if there is no reactNamespace/jsxFactory's symbol in scope when targeting React emit, we should issue an error.
|
||||
const reactRefErr = compilerOptions.jsx === JsxEmit.React ? Diagnostics.Cannot_find_name_0 : undefined;
|
||||
const reactNamespace = getJsxNamespace();
|
||||
|
||||
@ -476,7 +476,7 @@ namespace ts {
|
||||
return resolveModuleNamesWorker(moduleNames, containingFile);
|
||||
}
|
||||
|
||||
// at this point we know that either
|
||||
// at this point we know that either
|
||||
// - file has local declarations for ambient modules
|
||||
// OR
|
||||
// - old program state is available
|
||||
@ -670,7 +670,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
const modifiedFilePaths = modifiedSourceFiles.map(f => f.newFile.path);
|
||||
// try to verify results of module resolution
|
||||
// try to verify results of module resolution
|
||||
for (const { oldFile: oldSourceFile, newFile: newSourceFile } of modifiedSourceFiles) {
|
||||
const newSourceFilePath = getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory);
|
||||
if (resolveModuleNamesWorker) {
|
||||
@ -1447,7 +1447,9 @@ namespace ts {
|
||||
collectExternalModuleReferences(file);
|
||||
if (file.imports.length || file.moduleAugmentations.length) {
|
||||
file.resolvedModules = createMap<ResolvedModuleFull>();
|
||||
const moduleNames = map(concatenate(file.imports, file.moduleAugmentations), getTextOfLiteral);
|
||||
// Because global augmentation doesn't have string literal name, we can check for global augmentation as such.
|
||||
const nonGlobalAugmentation = filter(file.moduleAugmentations, (moduleAugmentation) => moduleAugmentation.kind === SyntaxKind.StringLiteral);
|
||||
const moduleNames = map(concatenate(file.imports, nonGlobalAugmentation), getTextOfLiteral);
|
||||
const resolutions = resolveModuleNamesReusingOldState(moduleNames, getNormalizedAbsolutePath(file.fileName, currentDirectory), file);
|
||||
Debug.assert(resolutions.length === moduleNames.length);
|
||||
for (let i = 0; i < moduleNames.length; i++) {
|
||||
|
||||
@ -471,7 +471,11 @@ namespace ts {
|
||||
currentSourceFile = node;
|
||||
|
||||
// ensure "use strict" is emitted in all scenarios in alwaysStrict mode
|
||||
if (compilerOptions.alwaysStrict) {
|
||||
// There is no need to emit "use strict" in the following cases:
|
||||
// 1. The file is an external module and target is es2015 or higher
|
||||
// or 2. The file is an external module and module-kind is es6 or es2015 as such value is not allowed when targeting es5 or lower
|
||||
if (compilerOptions.alwaysStrict &&
|
||||
!(isExternalModule(node) && (compilerOptions.target >= ScriptTarget.ES2015 || compilerOptions.module === ModuleKind.ES2015))) {
|
||||
node = ensureUseStrict(node);
|
||||
}
|
||||
|
||||
|
||||
@ -69,7 +69,7 @@ namespace ts.server.typingsInstaller {
|
||||
requestId: number;
|
||||
args: string[];
|
||||
cwd: string;
|
||||
onRequestCompleted: RequestCompletedAction
|
||||
onRequestCompleted: RequestCompletedAction;
|
||||
};
|
||||
|
||||
export abstract class TypingsInstaller {
|
||||
@ -380,7 +380,7 @@ namespace ts.server.typingsInstaller {
|
||||
compilerOptions: request.compilerOptions,
|
||||
typings,
|
||||
unresolvedImports: request.unresolvedImports,
|
||||
kind: server.ActionSet
|
||||
kind: ActionSet
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
8
tests/baselines/reference/alwaysStrictModule3.js
Normal file
8
tests/baselines/reference/alwaysStrictModule3.js
Normal file
@ -0,0 +1,8 @@
|
||||
//// [alwaysStrictModule3.ts]
|
||||
|
||||
// module ES2015
|
||||
export const a = 1;
|
||||
|
||||
//// [alwaysStrictModule3.js]
|
||||
// module ES2015
|
||||
export var a = 1;
|
||||
6
tests/baselines/reference/alwaysStrictModule3.symbols
Normal file
6
tests/baselines/reference/alwaysStrictModule3.symbols
Normal file
@ -0,0 +1,6 @@
|
||||
=== tests/cases/compiler/alwaysStrictModule3.ts ===
|
||||
|
||||
// module ES2015
|
||||
export const a = 1;
|
||||
>a : Symbol(a, Decl(alwaysStrictModule3.ts, 2, 12))
|
||||
|
||||
7
tests/baselines/reference/alwaysStrictModule3.types
Normal file
7
tests/baselines/reference/alwaysStrictModule3.types
Normal file
@ -0,0 +1,7 @@
|
||||
=== tests/cases/compiler/alwaysStrictModule3.ts ===
|
||||
|
||||
// module ES2015
|
||||
export const a = 1;
|
||||
>a : 1
|
||||
>1 : 1
|
||||
|
||||
9
tests/baselines/reference/alwaysStrictModule4.js
Normal file
9
tests/baselines/reference/alwaysStrictModule4.js
Normal file
@ -0,0 +1,9 @@
|
||||
//// [alwaysStrictModule4.ts]
|
||||
|
||||
// Module commonjs
|
||||
export const a = 1
|
||||
|
||||
//// [alwaysStrictModule4.js]
|
||||
"use strict";
|
||||
// Module commonjs
|
||||
exports.a = 1;
|
||||
6
tests/baselines/reference/alwaysStrictModule4.symbols
Normal file
6
tests/baselines/reference/alwaysStrictModule4.symbols
Normal file
@ -0,0 +1,6 @@
|
||||
=== tests/cases/compiler/alwaysStrictModule4.ts ===
|
||||
|
||||
// Module commonjs
|
||||
export const a = 1
|
||||
>a : Symbol(a, Decl(alwaysStrictModule4.ts, 2, 12))
|
||||
|
||||
7
tests/baselines/reference/alwaysStrictModule4.types
Normal file
7
tests/baselines/reference/alwaysStrictModule4.types
Normal file
@ -0,0 +1,7 @@
|
||||
=== tests/cases/compiler/alwaysStrictModule4.ts ===
|
||||
|
||||
// Module commonjs
|
||||
export const a = 1
|
||||
>a : 1
|
||||
>1 : 1
|
||||
|
||||
8
tests/baselines/reference/alwaysStrictModule5.js
Normal file
8
tests/baselines/reference/alwaysStrictModule5.js
Normal file
@ -0,0 +1,8 @@
|
||||
//// [alwaysStrictModule5.ts]
|
||||
|
||||
// Targeting ES6
|
||||
export const a = 1;
|
||||
|
||||
//// [alwaysStrictModule5.js]
|
||||
// Targeting ES6
|
||||
export const a = 1;
|
||||
6
tests/baselines/reference/alwaysStrictModule5.symbols
Normal file
6
tests/baselines/reference/alwaysStrictModule5.symbols
Normal file
@ -0,0 +1,6 @@
|
||||
=== tests/cases/compiler/alwaysStrictModule5.ts ===
|
||||
|
||||
// Targeting ES6
|
||||
export const a = 1;
|
||||
>a : Symbol(a, Decl(alwaysStrictModule5.ts, 2, 12))
|
||||
|
||||
7
tests/baselines/reference/alwaysStrictModule5.types
Normal file
7
tests/baselines/reference/alwaysStrictModule5.types
Normal file
@ -0,0 +1,7 @@
|
||||
=== tests/cases/compiler/alwaysStrictModule5.ts ===
|
||||
|
||||
// Targeting ES6
|
||||
export const a = 1;
|
||||
>a : 1
|
||||
>1 : 1
|
||||
|
||||
9
tests/baselines/reference/alwaysStrictModule6.js
Normal file
9
tests/baselines/reference/alwaysStrictModule6.js
Normal file
@ -0,0 +1,9 @@
|
||||
//// [alwaysStrictModule6.ts]
|
||||
|
||||
// Targeting ES5
|
||||
export const a = 1;
|
||||
|
||||
//// [alwaysStrictModule6.js]
|
||||
"use strict";
|
||||
// Targeting ES5
|
||||
exports.a = 1;
|
||||
6
tests/baselines/reference/alwaysStrictModule6.symbols
Normal file
6
tests/baselines/reference/alwaysStrictModule6.symbols
Normal file
@ -0,0 +1,6 @@
|
||||
=== tests/cases/compiler/alwaysStrictModule6.ts ===
|
||||
|
||||
// Targeting ES5
|
||||
export const a = 1;
|
||||
>a : Symbol(a, Decl(alwaysStrictModule6.ts, 2, 12))
|
||||
|
||||
7
tests/baselines/reference/alwaysStrictModule6.types
Normal file
7
tests/baselines/reference/alwaysStrictModule6.types
Normal file
@ -0,0 +1,7 @@
|
||||
=== tests/cases/compiler/alwaysStrictModule6.ts ===
|
||||
|
||||
// Targeting ES5
|
||||
export const a = 1;
|
||||
>a : 1
|
||||
>1 : 1
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
//// [declarationEmitTypeAliasWithTypeParameters2.ts]
|
||||
|
||||
export type Bar<X, Y, Z> = () => [X, Y, Z];
|
||||
export type Baz<M, N> = Bar<M, string, N>;
|
||||
export type Baa<Y> = Baz<boolean, Y>;
|
||||
export const y = (x: Baa<number>) => 1
|
||||
|
||||
//// [declarationEmitTypeAliasWithTypeParameters2.js]
|
||||
"use strict";
|
||||
exports.y = function (x) { return 1; };
|
||||
|
||||
|
||||
//// [declarationEmitTypeAliasWithTypeParameters2.d.ts]
|
||||
export declare type Bar<X, Y, Z> = () => [X, Y, Z];
|
||||
export declare type Baz<M, N> = Bar<M, string, N>;
|
||||
export declare type Baa<Y> = Baz<boolean, Y>;
|
||||
export declare const y: (x: Bar<boolean, string, number>) => number;
|
||||
@ -0,0 +1,30 @@
|
||||
=== tests/cases/compiler/declarationEmitTypeAliasWithTypeParameters2.ts ===
|
||||
|
||||
export type Bar<X, Y, Z> = () => [X, Y, Z];
|
||||
>Bar : Symbol(Bar, Decl(declarationEmitTypeAliasWithTypeParameters2.ts, 0, 0))
|
||||
>X : Symbol(X, Decl(declarationEmitTypeAliasWithTypeParameters2.ts, 1, 16))
|
||||
>Y : Symbol(Y, Decl(declarationEmitTypeAliasWithTypeParameters2.ts, 1, 18))
|
||||
>Z : Symbol(Z, Decl(declarationEmitTypeAliasWithTypeParameters2.ts, 1, 21))
|
||||
>X : Symbol(X, Decl(declarationEmitTypeAliasWithTypeParameters2.ts, 1, 16))
|
||||
>Y : Symbol(Y, Decl(declarationEmitTypeAliasWithTypeParameters2.ts, 1, 18))
|
||||
>Z : Symbol(Z, Decl(declarationEmitTypeAliasWithTypeParameters2.ts, 1, 21))
|
||||
|
||||
export type Baz<M, N> = Bar<M, string, N>;
|
||||
>Baz : Symbol(Baz, Decl(declarationEmitTypeAliasWithTypeParameters2.ts, 1, 43))
|
||||
>M : Symbol(M, Decl(declarationEmitTypeAliasWithTypeParameters2.ts, 2, 16))
|
||||
>N : Symbol(N, Decl(declarationEmitTypeAliasWithTypeParameters2.ts, 2, 18))
|
||||
>Bar : Symbol(Bar, Decl(declarationEmitTypeAliasWithTypeParameters2.ts, 0, 0))
|
||||
>M : Symbol(M, Decl(declarationEmitTypeAliasWithTypeParameters2.ts, 2, 16))
|
||||
>N : Symbol(N, Decl(declarationEmitTypeAliasWithTypeParameters2.ts, 2, 18))
|
||||
|
||||
export type Baa<Y> = Baz<boolean, Y>;
|
||||
>Baa : Symbol(Baa, Decl(declarationEmitTypeAliasWithTypeParameters2.ts, 2, 42))
|
||||
>Y : Symbol(Y, Decl(declarationEmitTypeAliasWithTypeParameters2.ts, 3, 16))
|
||||
>Baz : Symbol(Baz, Decl(declarationEmitTypeAliasWithTypeParameters2.ts, 1, 43))
|
||||
>Y : Symbol(Y, Decl(declarationEmitTypeAliasWithTypeParameters2.ts, 3, 16))
|
||||
|
||||
export const y = (x: Baa<number>) => 1
|
||||
>y : Symbol(y, Decl(declarationEmitTypeAliasWithTypeParameters2.ts, 4, 12))
|
||||
>x : Symbol(x, Decl(declarationEmitTypeAliasWithTypeParameters2.ts, 4, 18))
|
||||
>Baa : Symbol(Baa, Decl(declarationEmitTypeAliasWithTypeParameters2.ts, 2, 42))
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
=== tests/cases/compiler/declarationEmitTypeAliasWithTypeParameters2.ts ===
|
||||
|
||||
export type Bar<X, Y, Z> = () => [X, Y, Z];
|
||||
>Bar : Bar<X, Y, Z>
|
||||
>X : X
|
||||
>Y : Y
|
||||
>Z : Z
|
||||
>X : X
|
||||
>Y : Y
|
||||
>Z : Z
|
||||
|
||||
export type Baz<M, N> = Bar<M, string, N>;
|
||||
>Baz : Bar<M, string, N>
|
||||
>M : M
|
||||
>N : N
|
||||
>Bar : Bar<X, Y, Z>
|
||||
>M : M
|
||||
>N : N
|
||||
|
||||
export type Baa<Y> = Baz<boolean, Y>;
|
||||
>Baa : Bar<boolean, string, Y>
|
||||
>Y : Y
|
||||
>Baz : Bar<M, string, N>
|
||||
>Y : Y
|
||||
|
||||
export const y = (x: Baa<number>) => 1
|
||||
>y : (x: Bar<boolean, string, number>) => number
|
||||
>(x: Baa<number>) => 1 : (x: Bar<boolean, string, number>) => number
|
||||
>x : Bar<boolean, string, number>
|
||||
>Baa : Bar<boolean, string, Y>
|
||||
>1 : 1
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
//// [declarationEmitTypeAliasWithTypeParameters3.ts]
|
||||
|
||||
type Foo<T> = {
|
||||
foo<U>(): Foo<U>
|
||||
};
|
||||
function bar() {
|
||||
return {} as Foo<number>;
|
||||
}
|
||||
|
||||
|
||||
//// [declarationEmitTypeAliasWithTypeParameters3.js]
|
||||
function bar() {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
//// [declarationEmitTypeAliasWithTypeParameters3.d.ts]
|
||||
declare type Foo<T> = {
|
||||
foo<U>(): Foo<U>;
|
||||
};
|
||||
declare function bar(): Foo<number>;
|
||||
@ -0,0 +1,20 @@
|
||||
=== tests/cases/compiler/declarationEmitTypeAliasWithTypeParameters3.ts ===
|
||||
|
||||
type Foo<T> = {
|
||||
>Foo : Symbol(Foo, Decl(declarationEmitTypeAliasWithTypeParameters3.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(declarationEmitTypeAliasWithTypeParameters3.ts, 1, 9))
|
||||
|
||||
foo<U>(): Foo<U>
|
||||
>foo : Symbol(foo, Decl(declarationEmitTypeAliasWithTypeParameters3.ts, 1, 15))
|
||||
>U : Symbol(U, Decl(declarationEmitTypeAliasWithTypeParameters3.ts, 2, 8))
|
||||
>Foo : Symbol(Foo, Decl(declarationEmitTypeAliasWithTypeParameters3.ts, 0, 0))
|
||||
>U : Symbol(U, Decl(declarationEmitTypeAliasWithTypeParameters3.ts, 2, 8))
|
||||
|
||||
};
|
||||
function bar() {
|
||||
>bar : Symbol(bar, Decl(declarationEmitTypeAliasWithTypeParameters3.ts, 3, 2))
|
||||
|
||||
return {} as Foo<number>;
|
||||
>Foo : Symbol(Foo, Decl(declarationEmitTypeAliasWithTypeParameters3.ts, 0, 0))
|
||||
}
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
=== tests/cases/compiler/declarationEmitTypeAliasWithTypeParameters3.ts ===
|
||||
|
||||
type Foo<T> = {
|
||||
>Foo : Foo<T>
|
||||
>T : T
|
||||
|
||||
foo<U>(): Foo<U>
|
||||
>foo : <U>() => Foo<U>
|
||||
>U : U
|
||||
>Foo : Foo<T>
|
||||
>U : U
|
||||
|
||||
};
|
||||
function bar() {
|
||||
>bar : () => Foo<number>
|
||||
|
||||
return {} as Foo<number>;
|
||||
>{} as Foo<number> : Foo<number>
|
||||
>{} : {}
|
||||
>Foo : Foo<T>
|
||||
}
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
//// [declarationEmitTypeAliasWithTypeParameters4.ts]
|
||||
|
||||
type Foo<T, Y> = {
|
||||
foo<U, J>(): Foo<U, J>
|
||||
};
|
||||
type SubFoo<R> = Foo<string, R>;
|
||||
|
||||
function foo() {
|
||||
return {} as SubFoo<number>;
|
||||
}
|
||||
|
||||
|
||||
//// [declarationEmitTypeAliasWithTypeParameters4.js]
|
||||
function foo() {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
//// [declarationEmitTypeAliasWithTypeParameters4.d.ts]
|
||||
declare type Foo<T, Y> = {
|
||||
foo<U, J>(): Foo<U, J>;
|
||||
};
|
||||
declare type SubFoo<R> = Foo<string, R>;
|
||||
declare function foo(): Foo<string, number>;
|
||||
@ -0,0 +1,29 @@
|
||||
=== tests/cases/compiler/declarationEmitTypeAliasWithTypeParameters4.ts ===
|
||||
|
||||
type Foo<T, Y> = {
|
||||
>Foo : Symbol(Foo, Decl(declarationEmitTypeAliasWithTypeParameters4.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(declarationEmitTypeAliasWithTypeParameters4.ts, 1, 9))
|
||||
>Y : Symbol(Y, Decl(declarationEmitTypeAliasWithTypeParameters4.ts, 1, 11))
|
||||
|
||||
foo<U, J>(): Foo<U, J>
|
||||
>foo : Symbol(foo, Decl(declarationEmitTypeAliasWithTypeParameters4.ts, 1, 18))
|
||||
>U : Symbol(U, Decl(declarationEmitTypeAliasWithTypeParameters4.ts, 2, 8))
|
||||
>J : Symbol(J, Decl(declarationEmitTypeAliasWithTypeParameters4.ts, 2, 10))
|
||||
>Foo : Symbol(Foo, Decl(declarationEmitTypeAliasWithTypeParameters4.ts, 0, 0))
|
||||
>U : Symbol(U, Decl(declarationEmitTypeAliasWithTypeParameters4.ts, 2, 8))
|
||||
>J : Symbol(J, Decl(declarationEmitTypeAliasWithTypeParameters4.ts, 2, 10))
|
||||
|
||||
};
|
||||
type SubFoo<R> = Foo<string, R>;
|
||||
>SubFoo : Symbol(SubFoo, Decl(declarationEmitTypeAliasWithTypeParameters4.ts, 3, 2))
|
||||
>R : Symbol(R, Decl(declarationEmitTypeAliasWithTypeParameters4.ts, 4, 12))
|
||||
>Foo : Symbol(Foo, Decl(declarationEmitTypeAliasWithTypeParameters4.ts, 0, 0))
|
||||
>R : Symbol(R, Decl(declarationEmitTypeAliasWithTypeParameters4.ts, 4, 12))
|
||||
|
||||
function foo() {
|
||||
>foo : Symbol(foo, Decl(declarationEmitTypeAliasWithTypeParameters4.ts, 4, 32))
|
||||
|
||||
return {} as SubFoo<number>;
|
||||
>SubFoo : Symbol(SubFoo, Decl(declarationEmitTypeAliasWithTypeParameters4.ts, 3, 2))
|
||||
}
|
||||
|
||||
@ -0,0 +1,31 @@
|
||||
=== tests/cases/compiler/declarationEmitTypeAliasWithTypeParameters4.ts ===
|
||||
|
||||
type Foo<T, Y> = {
|
||||
>Foo : Foo<T, Y>
|
||||
>T : T
|
||||
>Y : Y
|
||||
|
||||
foo<U, J>(): Foo<U, J>
|
||||
>foo : <U, J>() => Foo<U, J>
|
||||
>U : U
|
||||
>J : J
|
||||
>Foo : Foo<T, Y>
|
||||
>U : U
|
||||
>J : J
|
||||
|
||||
};
|
||||
type SubFoo<R> = Foo<string, R>;
|
||||
>SubFoo : Foo<string, R>
|
||||
>R : R
|
||||
>Foo : Foo<T, Y>
|
||||
>R : R
|
||||
|
||||
function foo() {
|
||||
>foo : () => Foo<string, number>
|
||||
|
||||
return {} as SubFoo<number>;
|
||||
>{} as SubFoo<number> : Foo<string, number>
|
||||
>{} : {}
|
||||
>SubFoo : Foo<string, R>
|
||||
}
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
tests/cases/compiler/declarationEmitTypeAliasWithTypeParameters5.ts(5,25): error TS4081: Exported type alias 'SubFoo' has or is using private name 'Foo'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/declarationEmitTypeAliasWithTypeParameters5.ts (1 errors) ====
|
||||
|
||||
type Foo<T, Y> = {
|
||||
foo<U, J>(): Foo<U, J>
|
||||
};
|
||||
export type SubFoo<R> = Foo<string, R>;
|
||||
~~~
|
||||
!!! error TS4081: Exported type alias 'SubFoo' has or is using private name 'Foo'.
|
||||
|
||||
function foo() {
|
||||
return {} as SubFoo<number>;
|
||||
}
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
//// [declarationEmitTypeAliasWithTypeParameters5.ts]
|
||||
|
||||
type Foo<T, Y> = {
|
||||
foo<U, J>(): Foo<U, J>
|
||||
};
|
||||
export type SubFoo<R> = Foo<string, R>;
|
||||
|
||||
function foo() {
|
||||
return {} as SubFoo<number>;
|
||||
}
|
||||
|
||||
|
||||
//// [declarationEmitTypeAliasWithTypeParameters5.js]
|
||||
"use strict";
|
||||
function foo() {
|
||||
return {};
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
//// [declarationEmitTypeAliasWithTypeParameters6.ts]
|
||||
|
||||
type Foo<T, Y> = {
|
||||
foo<U, J>(): Foo<U, J>
|
||||
};
|
||||
type SubFoo<R, S> = Foo<S, R>;
|
||||
|
||||
function foo() {
|
||||
return {} as SubFoo<number, string>;
|
||||
}
|
||||
|
||||
|
||||
//// [declarationEmitTypeAliasWithTypeParameters6.js]
|
||||
function foo() {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
//// [declarationEmitTypeAliasWithTypeParameters6.d.ts]
|
||||
declare type Foo<T, Y> = {
|
||||
foo<U, J>(): Foo<U, J>;
|
||||
};
|
||||
declare type SubFoo<R, S> = Foo<S, R>;
|
||||
declare function foo(): Foo<string, number>;
|
||||
@ -0,0 +1,31 @@
|
||||
=== tests/cases/compiler/declarationEmitTypeAliasWithTypeParameters6.ts ===
|
||||
|
||||
type Foo<T, Y> = {
|
||||
>Foo : Symbol(Foo, Decl(declarationEmitTypeAliasWithTypeParameters6.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(declarationEmitTypeAliasWithTypeParameters6.ts, 1, 9))
|
||||
>Y : Symbol(Y, Decl(declarationEmitTypeAliasWithTypeParameters6.ts, 1, 11))
|
||||
|
||||
foo<U, J>(): Foo<U, J>
|
||||
>foo : Symbol(foo, Decl(declarationEmitTypeAliasWithTypeParameters6.ts, 1, 18))
|
||||
>U : Symbol(U, Decl(declarationEmitTypeAliasWithTypeParameters6.ts, 2, 8))
|
||||
>J : Symbol(J, Decl(declarationEmitTypeAliasWithTypeParameters6.ts, 2, 10))
|
||||
>Foo : Symbol(Foo, Decl(declarationEmitTypeAliasWithTypeParameters6.ts, 0, 0))
|
||||
>U : Symbol(U, Decl(declarationEmitTypeAliasWithTypeParameters6.ts, 2, 8))
|
||||
>J : Symbol(J, Decl(declarationEmitTypeAliasWithTypeParameters6.ts, 2, 10))
|
||||
|
||||
};
|
||||
type SubFoo<R, S> = Foo<S, R>;
|
||||
>SubFoo : Symbol(SubFoo, Decl(declarationEmitTypeAliasWithTypeParameters6.ts, 3, 2))
|
||||
>R : Symbol(R, Decl(declarationEmitTypeAliasWithTypeParameters6.ts, 4, 12))
|
||||
>S : Symbol(S, Decl(declarationEmitTypeAliasWithTypeParameters6.ts, 4, 14))
|
||||
>Foo : Symbol(Foo, Decl(declarationEmitTypeAliasWithTypeParameters6.ts, 0, 0))
|
||||
>S : Symbol(S, Decl(declarationEmitTypeAliasWithTypeParameters6.ts, 4, 14))
|
||||
>R : Symbol(R, Decl(declarationEmitTypeAliasWithTypeParameters6.ts, 4, 12))
|
||||
|
||||
function foo() {
|
||||
>foo : Symbol(foo, Decl(declarationEmitTypeAliasWithTypeParameters6.ts, 4, 30))
|
||||
|
||||
return {} as SubFoo<number, string>;
|
||||
>SubFoo : Symbol(SubFoo, Decl(declarationEmitTypeAliasWithTypeParameters6.ts, 3, 2))
|
||||
}
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
=== tests/cases/compiler/declarationEmitTypeAliasWithTypeParameters6.ts ===
|
||||
|
||||
type Foo<T, Y> = {
|
||||
>Foo : Foo<T, Y>
|
||||
>T : T
|
||||
>Y : Y
|
||||
|
||||
foo<U, J>(): Foo<U, J>
|
||||
>foo : <U, J>() => Foo<U, J>
|
||||
>U : U
|
||||
>J : J
|
||||
>Foo : Foo<T, Y>
|
||||
>U : U
|
||||
>J : J
|
||||
|
||||
};
|
||||
type SubFoo<R, S> = Foo<S, R>;
|
||||
>SubFoo : Foo<S, R>
|
||||
>R : R
|
||||
>S : S
|
||||
>Foo : Foo<T, Y>
|
||||
>S : S
|
||||
>R : R
|
||||
|
||||
function foo() {
|
||||
>foo : () => Foo<string, number>
|
||||
|
||||
return {} as SubFoo<number, string>;
|
||||
>{} as SubFoo<number, string> : Foo<string, number>
|
||||
>{} : {}
|
||||
>SubFoo : Foo<S, R>
|
||||
}
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
//// [a.ts]
|
||||
|
||||
export { };
|
||||
|
||||
declare global {
|
||||
var x: number;
|
||||
}
|
||||
|
||||
//// [a.js]
|
||||
"use strict";
|
||||
@ -0,0 +1,10 @@
|
||||
=== tests/cases/conformance/externalModules/a.ts ===
|
||||
|
||||
export { };
|
||||
|
||||
declare global {
|
||||
>global : Symbol(global, Decl(a.ts, 1, 11))
|
||||
|
||||
var x: number;
|
||||
>x : Symbol(x, Decl(a.ts, 4, 5))
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
[]
|
||||
@ -0,0 +1,10 @@
|
||||
=== tests/cases/conformance/externalModules/a.ts ===
|
||||
|
||||
export { };
|
||||
|
||||
declare global {
|
||||
>global : any
|
||||
|
||||
var x: number;
|
||||
>x : number
|
||||
}
|
||||
5
tests/cases/compiler/alwaysStrictModule3.ts
Normal file
5
tests/cases/compiler/alwaysStrictModule3.ts
Normal file
@ -0,0 +1,5 @@
|
||||
// @alwaysStrict: true
|
||||
// @module: es2015
|
||||
|
||||
// module ES2015
|
||||
export const a = 1;
|
||||
5
tests/cases/compiler/alwaysStrictModule4.ts
Normal file
5
tests/cases/compiler/alwaysStrictModule4.ts
Normal file
@ -0,0 +1,5 @@
|
||||
// @alwaysStrict: true
|
||||
// @module: commonjs
|
||||
|
||||
// Module commonjs
|
||||
export const a = 1
|
||||
5
tests/cases/compiler/alwaysStrictModule5.ts
Normal file
5
tests/cases/compiler/alwaysStrictModule5.ts
Normal file
@ -0,0 +1,5 @@
|
||||
// @alwaysStrict: true
|
||||
// @target: es6
|
||||
|
||||
// Targeting ES6
|
||||
export const a = 1;
|
||||
5
tests/cases/compiler/alwaysStrictModule6.ts
Normal file
5
tests/cases/compiler/alwaysStrictModule6.ts
Normal file
@ -0,0 +1,5 @@
|
||||
// @alwaysStrict: true
|
||||
// @target: es5
|
||||
|
||||
// Targeting ES5
|
||||
export const a = 1;
|
||||
@ -0,0 +1,6 @@
|
||||
// @declaration: true
|
||||
|
||||
export type Bar<X, Y, Z> = () => [X, Y, Z];
|
||||
export type Baz<M, N> = Bar<M, string, N>;
|
||||
export type Baa<Y> = Baz<boolean, Y>;
|
||||
export const y = (x: Baa<number>) => 1
|
||||
@ -0,0 +1,8 @@
|
||||
// @declaration: true
|
||||
|
||||
type Foo<T> = {
|
||||
foo<U>(): Foo<U>
|
||||
};
|
||||
function bar() {
|
||||
return {} as Foo<number>;
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
// @declaration: true
|
||||
|
||||
type Foo<T, Y> = {
|
||||
foo<U, J>(): Foo<U, J>
|
||||
};
|
||||
type SubFoo<R> = Foo<string, R>;
|
||||
|
||||
function foo() {
|
||||
return {} as SubFoo<number>;
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
// @declaration: true
|
||||
|
||||
type Foo<T, Y> = {
|
||||
foo<U, J>(): Foo<U, J>
|
||||
};
|
||||
export type SubFoo<R> = Foo<string, R>;
|
||||
|
||||
function foo() {
|
||||
return {} as SubFoo<number>;
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
// @declaration: true
|
||||
|
||||
type Foo<T, Y> = {
|
||||
foo<U, J>(): Foo<U, J>
|
||||
};
|
||||
type SubFoo<R, S> = Foo<S, R>;
|
||||
|
||||
function foo() {
|
||||
return {} as SubFoo<number, string>;
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
// @traceResolution: true
|
||||
|
||||
// @fileName: a.ts
|
||||
export { };
|
||||
|
||||
declare global {
|
||||
var x: number;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user