mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'main' into staleErrors
This commit is contained in:
+42
-30
@@ -26519,7 +26519,7 @@ namespace ts {
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
if (!(contextFlags! & ContextFlags.SkipBindingPatterns) && isBindingPattern(declaration.name)) { // This is less a contextual type and more an implied shape - in some cases, this may be undesirable
|
||||
if (!(contextFlags! & ContextFlags.SkipBindingPatterns) && isBindingPattern(declaration.name) && declaration.name.elements.length > 0) {
|
||||
return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false);
|
||||
}
|
||||
}
|
||||
@@ -27053,22 +27053,20 @@ namespace ts {
|
||||
const inferenceContext = getInferenceContext(node);
|
||||
// If no inferences have been made, nothing is gained from instantiating as type parameters
|
||||
// would just be replaced with their defaults similar to the apparent type.
|
||||
if (inferenceContext && some(inferenceContext.inferences, hasInferenceCandidates)) {
|
||||
if (inferenceContext && contextFlags! & ContextFlags.Signature && some(inferenceContext.inferences, hasInferenceCandidates)) {
|
||||
// For contextual signatures we incorporate all inferences made so far, e.g. from return
|
||||
// types as well as arguments to the left in a function call.
|
||||
if (contextFlags && contextFlags & ContextFlags.Signature) {
|
||||
return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
|
||||
}
|
||||
return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
|
||||
}
|
||||
if (inferenceContext?.returnMapper) {
|
||||
// For other purposes (e.g. determining whether to produce literal types) we only
|
||||
// incorporate inferences made from the return type in a function call. We remove
|
||||
// the 'boolean' type from the contextual type such that contextually typed boolean
|
||||
// literals actually end up widening to 'boolean' (see #48363).
|
||||
if (inferenceContext.returnMapper) {
|
||||
const type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
|
||||
return type.flags & TypeFlags.Union && containsType((type as UnionType).types, regularFalseType) && containsType((type as UnionType).types, regularTrueType) ?
|
||||
filterType(type, t => t !== regularFalseType && t !== regularTrueType) :
|
||||
type;
|
||||
}
|
||||
const type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
|
||||
return type.flags & TypeFlags.Union && containsType((type as UnionType).types, regularFalseType) && containsType((type as UnionType).types, regularTrueType) ?
|
||||
filterType(type, t => t !== regularFalseType && t !== regularTrueType) :
|
||||
type;
|
||||
}
|
||||
}
|
||||
return contextualType;
|
||||
@@ -29904,29 +29902,43 @@ namespace ts {
|
||||
// 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the
|
||||
// return type of 'wrap'.
|
||||
if (node.kind !== SyntaxKind.Decorator) {
|
||||
const contextualType = getContextualType(node, every(signature.typeParameters, p => !!getDefaultFromTypeParameter(p)) ? ContextFlags.SkipBindingPatterns : ContextFlags.None);
|
||||
const skipBindingPatterns = every(signature.typeParameters, p => !!getDefaultFromTypeParameter(p));
|
||||
const contextualType = getContextualType(node, skipBindingPatterns ? ContextFlags.SkipBindingPatterns : ContextFlags.None);
|
||||
if (contextualType) {
|
||||
const inferenceTargetType = getReturnTypeOfSignature(signature);
|
||||
if (couldContainTypeVariables(inferenceTargetType)) {
|
||||
// We clone the inference context to avoid disturbing a resolution in progress for an
|
||||
// outer call expression. Effectively we just want a snapshot of whatever has been
|
||||
// inferred for any outer call expression so far.
|
||||
const outerContext = getInferenceContext(node);
|
||||
const outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, InferenceFlags.NoDefault));
|
||||
const instantiatedType = instantiateType(contextualType, outerMapper);
|
||||
// If the contextual type is a generic function type with a single call signature, we
|
||||
// instantiate the type with its own type parameters and type arguments. This ensures that
|
||||
// the type parameters are not erased to type any during type inference such that they can
|
||||
// be inferred as actual types from the contextual type. For example:
|
||||
// declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
|
||||
// const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
|
||||
// Above, the type of the 'value' parameter is inferred to be 'A'.
|
||||
const contextualSignature = getSingleCallSignature(instantiatedType);
|
||||
const inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
|
||||
getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
|
||||
instantiatedType;
|
||||
// Inferences made from return types have lower priority than all other inferences.
|
||||
inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, InferencePriority.ReturnType);
|
||||
const isFromBindingPattern = !skipBindingPatterns && getContextualType(node, ContextFlags.SkipBindingPatterns) !== contextualType;
|
||||
// A return type inference from a binding pattern can be used in instantiating the contextual
|
||||
// type of an argument later in inference, but cannot stand on its own as the final return type.
|
||||
// It is incorporated into `context.returnMapper` which is used in `instantiateContextualType`,
|
||||
// but doesn't need to go into `context.inferences`. This allows a an array binding pattern to
|
||||
// produce a tuple for `T` in
|
||||
// declare function f<T>(cb: () => T): T;
|
||||
// const [e1, e2, e3] = f(() => [1, "hi", true]);
|
||||
// but does not produce any inference for `T` in
|
||||
// declare function f<T>(): T;
|
||||
// const [e1, e2, e3] = f();
|
||||
if (!isFromBindingPattern) {
|
||||
// We clone the inference context to avoid disturbing a resolution in progress for an
|
||||
// outer call expression. Effectively we just want a snapshot of whatever has been
|
||||
// inferred for any outer call expression so far.
|
||||
const outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, InferenceFlags.NoDefault));
|
||||
const instantiatedType = instantiateType(contextualType, outerMapper);
|
||||
// If the contextual type is a generic function type with a single call signature, we
|
||||
// instantiate the type with its own type parameters and type arguments. This ensures that
|
||||
// the type parameters are not erased to type any during type inference such that they can
|
||||
// be inferred as actual types from the contextual type. For example:
|
||||
// declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
|
||||
// const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
|
||||
// Above, the type of the 'value' parameter is inferred to be 'A'.
|
||||
const contextualSignature = getSingleCallSignature(instantiatedType);
|
||||
const inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
|
||||
getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
|
||||
instantiatedType;
|
||||
// Inferences made from return types have lower priority than all other inferences.
|
||||
inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, InferencePriority.ReturnType);
|
||||
}
|
||||
// Create a type mapper for instantiating generic contextual types using the inferences made
|
||||
// from the return type. We need a separate inference pass here because (a) instantiation of
|
||||
// the source type uses the outer context's return mapper (which excludes inferences made from
|
||||
|
||||
@@ -3548,7 +3548,7 @@ namespace ts {
|
||||
}
|
||||
if (isImplicitGlob(spec.substring(spec.lastIndexOf(directorySeparator) + 1))) {
|
||||
return {
|
||||
key: useCaseSensitiveFileNames ? spec : toFileNameLowerCase(spec),
|
||||
key: removeTrailingDirectorySeparator(useCaseSensitiveFileNames ? spec : toFileNameLowerCase(spec)),
|
||||
flags: WatchDirectoryFlags.Recursive
|
||||
};
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace ts {
|
||||
// Though an error in es2020 modules, in node-flavor es2020 modules, we can helpfully transform this to a synthetic `require` call
|
||||
// To give easy access to a synchronous `require` in node-flavor esm. We do the transform even in scenarios where we error, but `import.meta.url`
|
||||
// is available, just because the output is reasonable for a node-like runtime.
|
||||
return getEmitScriptTarget(compilerOptions) >= ModuleKind.ES2020 ? visitImportEqualsDeclaration(node as ImportEqualsDeclaration) : undefined;
|
||||
return getEmitModuleKind(compilerOptions) >= ModuleKind.Node16 ? visitImportEqualsDeclaration(node as ImportEqualsDeclaration) : undefined;
|
||||
case SyntaxKind.ExportAssignment:
|
||||
return visitExportAssignment(node as ExportAssignment);
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
|
||||
@@ -5874,7 +5874,7 @@ namespace ts {
|
||||
ReturnType = 1 << 7, // Inference made from return type of generic function
|
||||
LiteralKeyof = 1 << 8, // Inference made from a string literal to a keyof T
|
||||
NoConstraints = 1 << 9, // Don't infer from constraints of instantiable types
|
||||
AlwaysStrict = 1 << 10, // Always use strict rules for contravariant inferences
|
||||
AlwaysStrict = 1 << 10, // Always use strict rules for contravariant inferences
|
||||
MaxValue = 1 << 11, // Seed for inference priority tracking
|
||||
|
||||
PriorityImpliesCombination = ReturnType | MappedTypeConstraint | LiteralKeyof, // These priorities imply that the resulting type should be a combination of all candidates
|
||||
@@ -8813,6 +8813,7 @@ namespace ts {
|
||||
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
|
||||
readonly includeInlayFunctionParameterTypeHints?: boolean,
|
||||
readonly includeInlayVariableTypeHints?: boolean;
|
||||
readonly includeInlayVariableTypeHintsWhenTypeMatchesName?: boolean;
|
||||
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
|
||||
readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
|
||||
readonly includeInlayEnumMemberValueHints?: boolean;
|
||||
|
||||
@@ -700,6 +700,7 @@ namespace ts {
|
||||
|
||||
function reloadFileNamesFromConfigFile() {
|
||||
writeLog("Reloading new file names and options");
|
||||
reloadLevel = ConfigFileProgramReloadLevel.None;
|
||||
rootFileNames = getFileNamesFromConfigSpecs(compilerOptions.configFile!.configFileSpecs!, getNormalizedAbsolutePath(getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost, extraFileExtensions);
|
||||
if (updateErrorForNoInputFiles(rootFileNames, getNormalizedAbsolutePath(configFileName, currentDirectory), compilerOptions.configFile!.configFileSpecs!, configFileParsingDiagnostics!, canConfigFileJsonReportNoInputFiles)) {
|
||||
hasChangedConfigFileParsingErrors = true;
|
||||
|
||||
@@ -1498,6 +1498,7 @@ namespace FourSlashInterface {
|
||||
"throw",
|
||||
"true",
|
||||
"try",
|
||||
"type",
|
||||
"typeof",
|
||||
"var",
|
||||
"void",
|
||||
@@ -1649,6 +1650,7 @@ namespace FourSlashInterface {
|
||||
"throw",
|
||||
"true",
|
||||
"try",
|
||||
"type",
|
||||
"typeof",
|
||||
"var",
|
||||
"void",
|
||||
|
||||
@@ -728,7 +728,7 @@ namespace ts.server.protocol {
|
||||
}
|
||||
|
||||
// All we need is the `success` and `message` fields of Response.
|
||||
export interface ApplyCodeActionCommandResponse extends Response {}
|
||||
export interface ApplyCodeActionCommandResponse extends Response { }
|
||||
|
||||
export interface FileRangeRequestArgs extends FileRequestArgs {
|
||||
/**
|
||||
@@ -1067,7 +1067,7 @@ namespace ts.server.protocol {
|
||||
readonly arguments: JsxClosingTagRequestArgs;
|
||||
}
|
||||
|
||||
export interface JsxClosingTagRequestArgs extends FileLocationRequestArgs {}
|
||||
export interface JsxClosingTagRequestArgs extends FileLocationRequestArgs { }
|
||||
|
||||
export interface JsxClosingTagResponse extends Response {
|
||||
readonly body: TextInsertion;
|
||||
@@ -2390,7 +2390,7 @@ namespace ts.server.protocol {
|
||||
/**
|
||||
* Human-readable description of the `source` from the CompletionEntry.
|
||||
*/
|
||||
sourceDisplay?: SymbolDisplayPart[];
|
||||
sourceDisplay?: SymbolDisplayPart[];
|
||||
}
|
||||
|
||||
/** @deprecated Prefer CompletionInfoResponse, which supports several top-level fields in addition to the array of entries. */
|
||||
@@ -3415,7 +3415,7 @@ namespace ts.server.protocol {
|
||||
/**
|
||||
* Allows completions to be formatted with snippet text, indicated by `CompletionItem["isSnippet"]`.
|
||||
*/
|
||||
readonly includeCompletionsWithSnippetText?: boolean;
|
||||
readonly includeCompletionsWithSnippetText?: boolean;
|
||||
/**
|
||||
* If enabled, the completion list will include completions with invalid identifier names.
|
||||
* For those entries, The `insertText` and `replacementSpan` properties will be set to change from `.x` property access to `["x"]`.
|
||||
@@ -3465,6 +3465,7 @@ namespace ts.server.protocol {
|
||||
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
|
||||
readonly includeInlayFunctionParameterTypeHints?: boolean,
|
||||
readonly includeInlayVariableTypeHints?: boolean;
|
||||
readonly includeInlayVariableTypeHintsWhenTypeMatchesName?: boolean;
|
||||
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
|
||||
readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
|
||||
readonly includeInlayEnumMemberValueHints?: boolean;
|
||||
|
||||
@@ -3988,6 +3988,7 @@ namespace ts.Completions {
|
||||
return kind === SyntaxKind.AsyncKeyword
|
||||
|| kind === SyntaxKind.AwaitKeyword
|
||||
|| kind === SyntaxKind.AsKeyword
|
||||
|| kind === SyntaxKind.TypeKeyword
|
||||
|| !isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind);
|
||||
}
|
||||
|
||||
|
||||
@@ -137,6 +137,10 @@ namespace ts.InlayHints {
|
||||
|
||||
const typeDisplayString = printTypeInSingleLine(declarationType);
|
||||
if (typeDisplayString) {
|
||||
const isVariableNameMatchesType = preferences.includeInlayVariableTypeHintsWhenTypeMatchesName === false && equateStringsCaseInsensitive(decl.name.getText(), typeDisplayString);
|
||||
if (isVariableNameMatchesType) {
|
||||
return;
|
||||
}
|
||||
addTypeHints(typeDisplayString, decl.name.end);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -421,5 +421,14 @@ namespace ts {
|
||||
const parsedCommand = parseJsonConfigFileContent(parsed.config, sys, "/foo.bar");
|
||||
assert.deepEqual(parsedCommand.wildcardDirectories, { "/foo.bar/src": WatchDirectoryFlags.Recursive });
|
||||
});
|
||||
|
||||
it("correctly parses wild card directories from implicit glob when two keys differ only in directory seperator", () => {
|
||||
const parsed = parseConfigFileTextToJson("/foo.bar/tsconfig.json", JSON.stringify({
|
||||
include: ["./", "./**/*.json"]
|
||||
}));
|
||||
|
||||
const parsedCommand = parseJsonConfigFileContent(parsed.config, sys, "/foo");
|
||||
assert.deepEqual(parsedCommand.wildcardDirectories, { "/foo": WatchDirectoryFlags.Recursive });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -616,6 +616,39 @@ export class A {
|
||||
]
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
scenario,
|
||||
subScenario: "correctly parses wild card directories from implicit glob when two keys differ only in directory seperator",
|
||||
commandLineArgs: ["-w", "--extendedDiagnostics"],
|
||||
sys: () => {
|
||||
const file1 = {
|
||||
path: `${projectRoot}/f1.ts`,
|
||||
content: "export const x = 1"
|
||||
};
|
||||
const file2 = {
|
||||
path: `${projectRoot}/f2.ts`,
|
||||
content: "export const y = 1"
|
||||
};
|
||||
const configFile = {
|
||||
path: `${projectRoot}/tsconfig.json`,
|
||||
content: JSON.stringify({ compilerOptions: { composite: true }, include: ["./", "./**/*.json"] })
|
||||
};
|
||||
return createWatchedSystem([file1, file2, libFile, configFile], { currentDirectory: projectRoot });
|
||||
},
|
||||
changes: [
|
||||
{
|
||||
caption: "Add new file",
|
||||
change: sys => sys.writeFile(`${projectRoot}/new-file.ts`, "export const z = 1;"),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
},
|
||||
{
|
||||
caption: "Import new file",
|
||||
change: sys => sys.prependFile(`${projectRoot}/f1.ts`, `import { z } from "./new-file";`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
scenario,
|
||||
subScenario: "can correctly update configured project when set of root files has changed through include",
|
||||
|
||||
@@ -4120,6 +4120,7 @@ declare namespace ts {
|
||||
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
|
||||
readonly includeInlayFunctionParameterTypeHints?: boolean;
|
||||
readonly includeInlayVariableTypeHints?: boolean;
|
||||
readonly includeInlayVariableTypeHintsWhenTypeMatchesName?: boolean;
|
||||
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
|
||||
readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
|
||||
readonly includeInlayEnumMemberValueHints?: boolean;
|
||||
@@ -9711,6 +9712,7 @@ declare namespace ts.server.protocol {
|
||||
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
|
||||
readonly includeInlayFunctionParameterTypeHints?: boolean;
|
||||
readonly includeInlayVariableTypeHints?: boolean;
|
||||
readonly includeInlayVariableTypeHintsWhenTypeMatchesName?: boolean;
|
||||
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
|
||||
readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
|
||||
readonly includeInlayEnumMemberValueHints?: boolean;
|
||||
|
||||
@@ -4120,6 +4120,7 @@ declare namespace ts {
|
||||
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
|
||||
readonly includeInlayFunctionParameterTypeHints?: boolean;
|
||||
readonly includeInlayVariableTypeHints?: boolean;
|
||||
readonly includeInlayVariableTypeHintsWhenTypeMatchesName?: boolean;
|
||||
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
|
||||
readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
|
||||
readonly includeInlayEnumMemberValueHints?: boolean;
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
tests/cases/compiler/bindingPatternCannotBeOnlyInferenceSource.ts(2,7): error TS2571: Object is of type 'unknown'.
|
||||
tests/cases/compiler/bindingPatternCannotBeOnlyInferenceSource.ts(3,9): error TS2339: Property 'p1' does not exist on type 'unknown'.
|
||||
tests/cases/compiler/bindingPatternCannotBeOnlyInferenceSource.ts(4,7): error TS2461: Type 'unknown' is not an array type.
|
||||
tests/cases/compiler/bindingPatternCannotBeOnlyInferenceSource.ts(4,7): error TS2571: Object is of type 'unknown'.
|
||||
tests/cases/compiler/bindingPatternCannotBeOnlyInferenceSource.ts(5,7): error TS2461: Type 'unknown' is not an array type.
|
||||
|
||||
|
||||
==== tests/cases/compiler/bindingPatternCannotBeOnlyInferenceSource.ts (5 errors) ====
|
||||
declare function f<T>(): T;
|
||||
const {} = f(); // error (only in strictNullChecks)
|
||||
~~
|
||||
!!! error TS2571: Object is of type 'unknown'.
|
||||
const { p1 } = f(); // error
|
||||
~~
|
||||
!!! error TS2339: Property 'p1' does not exist on type 'unknown'.
|
||||
const [] = f(); // error
|
||||
~~
|
||||
!!! error TS2461: Type 'unknown' is not an array type.
|
||||
~~
|
||||
!!! error TS2571: Object is of type 'unknown'.
|
||||
const [e1, e2] = f(); // error
|
||||
~~~~~~~~
|
||||
!!! error TS2461: Type 'unknown' is not an array type.
|
||||
|
||||
// Repro from #43605
|
||||
type Dispatch<A = { type: any; [extraProps: string]: any }> = { <T extends A>(action: T): T };
|
||||
type IFuncs = { readonly [key: string]: (...p: any) => void };
|
||||
type IDestructuring<T extends IFuncs> = { readonly [key in keyof T]?: (...p: Parameters<T[key]>) => void };
|
||||
type Destructuring<T extends IFuncs, U extends IDestructuring<T>> = (dispatch: Dispatch<any>, funcs: T) => U;
|
||||
const funcs1 = {
|
||||
funcA: (a: boolean): void => {},
|
||||
funcB: (b: string, bb: string): void => {},
|
||||
funcC: (c: number, cc: number, ccc: boolean): void => {},
|
||||
};
|
||||
type TFuncs1 = typeof funcs1;
|
||||
declare function useReduxDispatch1<T extends IDestructuring<TFuncs1>>(destructuring: Destructuring<TFuncs1, T>): T;
|
||||
const {} = useReduxDispatch1(
|
||||
(d, f) => ({
|
||||
funcA: (...p) => d(f.funcA(...p)), // p should be inferrable
|
||||
funcB: (...p) => d(f.funcB(...p)),
|
||||
funcC: (...p) => d(f.funcC(...p)),
|
||||
})
|
||||
);
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
//// [bindingPatternCannotBeOnlyInferenceSource.ts]
|
||||
declare function f<T>(): T;
|
||||
const {} = f(); // error (only in strictNullChecks)
|
||||
const { p1 } = f(); // error
|
||||
const [] = f(); // error
|
||||
const [e1, e2] = f(); // error
|
||||
|
||||
// Repro from #43605
|
||||
type Dispatch<A = { type: any; [extraProps: string]: any }> = { <T extends A>(action: T): T };
|
||||
type IFuncs = { readonly [key: string]: (...p: any) => void };
|
||||
type IDestructuring<T extends IFuncs> = { readonly [key in keyof T]?: (...p: Parameters<T[key]>) => void };
|
||||
type Destructuring<T extends IFuncs, U extends IDestructuring<T>> = (dispatch: Dispatch<any>, funcs: T) => U;
|
||||
const funcs1 = {
|
||||
funcA: (a: boolean): void => {},
|
||||
funcB: (b: string, bb: string): void => {},
|
||||
funcC: (c: number, cc: number, ccc: boolean): void => {},
|
||||
};
|
||||
type TFuncs1 = typeof funcs1;
|
||||
declare function useReduxDispatch1<T extends IDestructuring<TFuncs1>>(destructuring: Destructuring<TFuncs1, T>): T;
|
||||
const {} = useReduxDispatch1(
|
||||
(d, f) => ({
|
||||
funcA: (...p) => d(f.funcA(...p)), // p should be inferrable
|
||||
funcB: (...p) => d(f.funcB(...p)),
|
||||
funcC: (...p) => d(f.funcC(...p)),
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
//// [bindingPatternCannotBeOnlyInferenceSource.js]
|
||||
var _a = f(); // error (only in strictNullChecks)
|
||||
var p1 = f().p1; // error
|
||||
var _b = f(); // error
|
||||
var _c = f(), e1 = _c[0], e2 = _c[1]; // error
|
||||
var funcs1 = {
|
||||
funcA: function (a) { },
|
||||
funcB: function (b, bb) { },
|
||||
funcC: function (c, cc, ccc) { }
|
||||
};
|
||||
var _d = useReduxDispatch1(function (d, f) { return ({
|
||||
funcA: function () {
|
||||
var p = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
p[_i] = arguments[_i];
|
||||
}
|
||||
return d(f.funcA.apply(f, p));
|
||||
},
|
||||
funcB: function () {
|
||||
var p = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
p[_i] = arguments[_i];
|
||||
}
|
||||
return d(f.funcB.apply(f, p));
|
||||
},
|
||||
funcC: function () {
|
||||
var p = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
p[_i] = arguments[_i];
|
||||
}
|
||||
return d(f.funcC.apply(f, p));
|
||||
}
|
||||
}); });
|
||||
@@ -0,0 +1,133 @@
|
||||
=== tests/cases/compiler/bindingPatternCannotBeOnlyInferenceSource.ts ===
|
||||
declare function f<T>(): T;
|
||||
>f : Symbol(f, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 0, 19))
|
||||
>T : Symbol(T, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 0, 19))
|
||||
|
||||
const {} = f(); // error (only in strictNullChecks)
|
||||
>f : Symbol(f, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 0, 0))
|
||||
|
||||
const { p1 } = f(); // error
|
||||
>p1 : Symbol(p1, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 2, 7))
|
||||
>f : Symbol(f, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 0, 0))
|
||||
|
||||
const [] = f(); // error
|
||||
>f : Symbol(f, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 0, 0))
|
||||
|
||||
const [e1, e2] = f(); // error
|
||||
>e1 : Symbol(e1, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 4, 7))
|
||||
>e2 : Symbol(e2, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 4, 10))
|
||||
>f : Symbol(f, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 0, 0))
|
||||
|
||||
// Repro from #43605
|
||||
type Dispatch<A = { type: any; [extraProps: string]: any }> = { <T extends A>(action: T): T };
|
||||
>Dispatch : Symbol(Dispatch, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 4, 21))
|
||||
>A : Symbol(A, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 7, 14))
|
||||
>type : Symbol(type, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 7, 19))
|
||||
>extraProps : Symbol(extraProps, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 7, 32))
|
||||
>T : Symbol(T, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 7, 65))
|
||||
>A : Symbol(A, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 7, 14))
|
||||
>action : Symbol(action, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 7, 78))
|
||||
>T : Symbol(T, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 7, 65))
|
||||
>T : Symbol(T, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 7, 65))
|
||||
|
||||
type IFuncs = { readonly [key: string]: (...p: any) => void };
|
||||
>IFuncs : Symbol(IFuncs, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 7, 94))
|
||||
>key : Symbol(key, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 8, 26))
|
||||
>p : Symbol(p, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 8, 41))
|
||||
|
||||
type IDestructuring<T extends IFuncs> = { readonly [key in keyof T]?: (...p: Parameters<T[key]>) => void };
|
||||
>IDestructuring : Symbol(IDestructuring, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 8, 62))
|
||||
>T : Symbol(T, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 9, 20))
|
||||
>IFuncs : Symbol(IFuncs, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 7, 94))
|
||||
>key : Symbol(key, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 9, 52))
|
||||
>T : Symbol(T, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 9, 20))
|
||||
>p : Symbol(p, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 9, 71))
|
||||
>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 9, 20))
|
||||
>key : Symbol(key, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 9, 52))
|
||||
|
||||
type Destructuring<T extends IFuncs, U extends IDestructuring<T>> = (dispatch: Dispatch<any>, funcs: T) => U;
|
||||
>Destructuring : Symbol(Destructuring, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 9, 107))
|
||||
>T : Symbol(T, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 10, 19))
|
||||
>IFuncs : Symbol(IFuncs, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 7, 94))
|
||||
>U : Symbol(U, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 10, 36))
|
||||
>IDestructuring : Symbol(IDestructuring, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 8, 62))
|
||||
>T : Symbol(T, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 10, 19))
|
||||
>dispatch : Symbol(dispatch, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 10, 69))
|
||||
>Dispatch : Symbol(Dispatch, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 4, 21))
|
||||
>funcs : Symbol(funcs, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 10, 93))
|
||||
>T : Symbol(T, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 10, 19))
|
||||
>U : Symbol(U, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 10, 36))
|
||||
|
||||
const funcs1 = {
|
||||
>funcs1 : Symbol(funcs1, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 11, 5))
|
||||
|
||||
funcA: (a: boolean): void => {},
|
||||
>funcA : Symbol(funcA, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 11, 16))
|
||||
>a : Symbol(a, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 12, 12))
|
||||
|
||||
funcB: (b: string, bb: string): void => {},
|
||||
>funcB : Symbol(funcB, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 12, 36))
|
||||
>b : Symbol(b, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 13, 12))
|
||||
>bb : Symbol(bb, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 13, 22))
|
||||
|
||||
funcC: (c: number, cc: number, ccc: boolean): void => {},
|
||||
>funcC : Symbol(funcC, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 13, 47))
|
||||
>c : Symbol(c, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 14, 12))
|
||||
>cc : Symbol(cc, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 14, 22))
|
||||
>ccc : Symbol(ccc, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 14, 34))
|
||||
|
||||
};
|
||||
type TFuncs1 = typeof funcs1;
|
||||
>TFuncs1 : Symbol(TFuncs1, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 15, 2))
|
||||
>funcs1 : Symbol(funcs1, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 11, 5))
|
||||
|
||||
declare function useReduxDispatch1<T extends IDestructuring<TFuncs1>>(destructuring: Destructuring<TFuncs1, T>): T;
|
||||
>useReduxDispatch1 : Symbol(useReduxDispatch1, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 16, 29))
|
||||
>T : Symbol(T, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 17, 35))
|
||||
>IDestructuring : Symbol(IDestructuring, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 8, 62))
|
||||
>TFuncs1 : Symbol(TFuncs1, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 15, 2))
|
||||
>destructuring : Symbol(destructuring, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 17, 70))
|
||||
>Destructuring : Symbol(Destructuring, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 9, 107))
|
||||
>TFuncs1 : Symbol(TFuncs1, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 15, 2))
|
||||
>T : Symbol(T, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 17, 35))
|
||||
>T : Symbol(T, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 17, 35))
|
||||
|
||||
const {} = useReduxDispatch1(
|
||||
>useReduxDispatch1 : Symbol(useReduxDispatch1, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 16, 29))
|
||||
|
||||
(d, f) => ({
|
||||
>d : Symbol(d, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 19, 5))
|
||||
>f : Symbol(f, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 19, 7))
|
||||
|
||||
funcA: (...p) => d(f.funcA(...p)), // p should be inferrable
|
||||
>funcA : Symbol(funcA, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 19, 16))
|
||||
>p : Symbol(p, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 20, 16))
|
||||
>d : Symbol(d, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 19, 5))
|
||||
>f.funcA : Symbol(funcA, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 11, 16))
|
||||
>f : Symbol(f, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 19, 7))
|
||||
>funcA : Symbol(funcA, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 11, 16))
|
||||
>p : Symbol(p, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 20, 16))
|
||||
|
||||
funcB: (...p) => d(f.funcB(...p)),
|
||||
>funcB : Symbol(funcB, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 20, 42))
|
||||
>p : Symbol(p, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 21, 16))
|
||||
>d : Symbol(d, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 19, 5))
|
||||
>f.funcB : Symbol(funcB, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 12, 36))
|
||||
>f : Symbol(f, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 19, 7))
|
||||
>funcB : Symbol(funcB, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 12, 36))
|
||||
>p : Symbol(p, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 21, 16))
|
||||
|
||||
funcC: (...p) => d(f.funcC(...p)),
|
||||
>funcC : Symbol(funcC, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 21, 42))
|
||||
>p : Symbol(p, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 22, 16))
|
||||
>d : Symbol(d, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 19, 5))
|
||||
>f.funcC : Symbol(funcC, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 13, 47))
|
||||
>f : Symbol(f, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 19, 7))
|
||||
>funcC : Symbol(funcC, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 13, 47))
|
||||
>p : Symbol(p, Decl(bindingPatternCannotBeOnlyInferenceSource.ts, 22, 16))
|
||||
|
||||
})
|
||||
);
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
=== tests/cases/compiler/bindingPatternCannotBeOnlyInferenceSource.ts ===
|
||||
declare function f<T>(): T;
|
||||
>f : <T>() => T
|
||||
|
||||
const {} = f(); // error (only in strictNullChecks)
|
||||
>f() : unknown
|
||||
>f : <T>() => T
|
||||
|
||||
const { p1 } = f(); // error
|
||||
>p1 : any
|
||||
>f() : unknown
|
||||
>f : <T>() => T
|
||||
|
||||
const [] = f(); // error
|
||||
>f() : unknown
|
||||
>f : <T>() => T
|
||||
|
||||
const [e1, e2] = f(); // error
|
||||
>e1 : any
|
||||
>e2 : any
|
||||
>f() : unknown
|
||||
>f : <T>() => T
|
||||
|
||||
// Repro from #43605
|
||||
type Dispatch<A = { type: any; [extraProps: string]: any }> = { <T extends A>(action: T): T };
|
||||
>Dispatch : Dispatch<A>
|
||||
>type : any
|
||||
>extraProps : string
|
||||
>action : T
|
||||
|
||||
type IFuncs = { readonly [key: string]: (...p: any) => void };
|
||||
>IFuncs : { readonly [key: string]: (...p: any) => void; }
|
||||
>key : string
|
||||
>p : any
|
||||
|
||||
type IDestructuring<T extends IFuncs> = { readonly [key in keyof T]?: (...p: Parameters<T[key]>) => void };
|
||||
>IDestructuring : IDestructuring<T>
|
||||
>p : Parameters<T[key]>
|
||||
|
||||
type Destructuring<T extends IFuncs, U extends IDestructuring<T>> = (dispatch: Dispatch<any>, funcs: T) => U;
|
||||
>Destructuring : Destructuring<T, U>
|
||||
>dispatch : Dispatch<any>
|
||||
>funcs : T
|
||||
|
||||
const funcs1 = {
|
||||
>funcs1 : { funcA: (a: boolean) => void; funcB: (b: string, bb: string) => void; funcC: (c: number, cc: number, ccc: boolean) => void; }
|
||||
>{ funcA: (a: boolean): void => {}, funcB: (b: string, bb: string): void => {}, funcC: (c: number, cc: number, ccc: boolean): void => {},} : { funcA: (a: boolean) => void; funcB: (b: string, bb: string) => void; funcC: (c: number, cc: number, ccc: boolean) => void; }
|
||||
|
||||
funcA: (a: boolean): void => {},
|
||||
>funcA : (a: boolean) => void
|
||||
>(a: boolean): void => {} : (a: boolean) => void
|
||||
>a : boolean
|
||||
|
||||
funcB: (b: string, bb: string): void => {},
|
||||
>funcB : (b: string, bb: string) => void
|
||||
>(b: string, bb: string): void => {} : (b: string, bb: string) => void
|
||||
>b : string
|
||||
>bb : string
|
||||
|
||||
funcC: (c: number, cc: number, ccc: boolean): void => {},
|
||||
>funcC : (c: number, cc: number, ccc: boolean) => void
|
||||
>(c: number, cc: number, ccc: boolean): void => {} : (c: number, cc: number, ccc: boolean) => void
|
||||
>c : number
|
||||
>cc : number
|
||||
>ccc : boolean
|
||||
|
||||
};
|
||||
type TFuncs1 = typeof funcs1;
|
||||
>TFuncs1 : { funcA: (a: boolean) => void; funcB: (b: string, bb: string) => void; funcC: (c: number, cc: number, ccc: boolean) => void; }
|
||||
>funcs1 : { funcA: (a: boolean) => void; funcB: (b: string, bb: string) => void; funcC: (c: number, cc: number, ccc: boolean) => void; }
|
||||
|
||||
declare function useReduxDispatch1<T extends IDestructuring<TFuncs1>>(destructuring: Destructuring<TFuncs1, T>): T;
|
||||
>useReduxDispatch1 : <T extends IDestructuring<{ funcA: (a: boolean) => void; funcB: (b: string, bb: string) => void; funcC: (c: number, cc: number, ccc: boolean) => void; }>>(destructuring: Destructuring<TFuncs1, T>) => T
|
||||
>destructuring : Destructuring<{ funcA: (a: boolean) => void; funcB: (b: string, bb: string) => void; funcC: (c: number, cc: number, ccc: boolean) => void; }, T>
|
||||
|
||||
const {} = useReduxDispatch1(
|
||||
>useReduxDispatch1( (d, f) => ({ funcA: (...p) => d(f.funcA(...p)), // p should be inferrable funcB: (...p) => d(f.funcB(...p)), funcC: (...p) => d(f.funcC(...p)), })) : { funcA: (a: boolean) => void; funcB: (b: string, bb: string) => void; funcC: (c: number, cc: number, ccc: boolean) => void; }
|
||||
>useReduxDispatch1 : <T extends IDestructuring<{ funcA: (a: boolean) => void; funcB: (b: string, bb: string) => void; funcC: (c: number, cc: number, ccc: boolean) => void; }>>(destructuring: Destructuring<{ funcA: (a: boolean) => void; funcB: (b: string, bb: string) => void; funcC: (c: number, cc: number, ccc: boolean) => void; }, T>) => T
|
||||
|
||||
(d, f) => ({
|
||||
>(d, f) => ({ funcA: (...p) => d(f.funcA(...p)), // p should be inferrable funcB: (...p) => d(f.funcB(...p)), funcC: (...p) => d(f.funcC(...p)), }) : (d: Dispatch<any>, f: { funcA: (a: boolean) => void; funcB: (b: string, bb: string) => void; funcC: (c: number, cc: number, ccc: boolean) => void; }) => { funcA: (a: boolean) => void; funcB: (b: string, bb: string) => void; funcC: (c: number, cc: number, ccc: boolean) => void; }
|
||||
>d : Dispatch<any>
|
||||
>f : { funcA: (a: boolean) => void; funcB: (b: string, bb: string) => void; funcC: (c: number, cc: number, ccc: boolean) => void; }
|
||||
>({ funcA: (...p) => d(f.funcA(...p)), // p should be inferrable funcB: (...p) => d(f.funcB(...p)), funcC: (...p) => d(f.funcC(...p)), }) : { funcA: (a: boolean) => void; funcB: (b: string, bb: string) => void; funcC: (c: number, cc: number, ccc: boolean) => void; }
|
||||
>{ funcA: (...p) => d(f.funcA(...p)), // p should be inferrable funcB: (...p) => d(f.funcB(...p)), funcC: (...p) => d(f.funcC(...p)), } : { funcA: (a: boolean) => void; funcB: (b: string, bb: string) => void; funcC: (c: number, cc: number, ccc: boolean) => void; }
|
||||
|
||||
funcA: (...p) => d(f.funcA(...p)), // p should be inferrable
|
||||
>funcA : (a: boolean) => void
|
||||
>(...p) => d(f.funcA(...p)) : (a: boolean) => void
|
||||
>p : [a: boolean]
|
||||
>d(f.funcA(...p)) : void
|
||||
>d : Dispatch<any>
|
||||
>f.funcA(...p) : void
|
||||
>f.funcA : (a: boolean) => void
|
||||
>f : { funcA: (a: boolean) => void; funcB: (b: string, bb: string) => void; funcC: (c: number, cc: number, ccc: boolean) => void; }
|
||||
>funcA : (a: boolean) => void
|
||||
>...p : boolean
|
||||
>p : [a: boolean]
|
||||
|
||||
funcB: (...p) => d(f.funcB(...p)),
|
||||
>funcB : (b: string, bb: string) => void
|
||||
>(...p) => d(f.funcB(...p)) : (b: string, bb: string) => void
|
||||
>p : [b: string, bb: string]
|
||||
>d(f.funcB(...p)) : void
|
||||
>d : Dispatch<any>
|
||||
>f.funcB(...p) : void
|
||||
>f.funcB : (b: string, bb: string) => void
|
||||
>f : { funcA: (a: boolean) => void; funcB: (b: string, bb: string) => void; funcC: (c: number, cc: number, ccc: boolean) => void; }
|
||||
>funcB : (b: string, bb: string) => void
|
||||
>...p : string
|
||||
>p : [b: string, bb: string]
|
||||
|
||||
funcC: (...p) => d(f.funcC(...p)),
|
||||
>funcC : (c: number, cc: number, ccc: boolean) => void
|
||||
>(...p) => d(f.funcC(...p)) : (c: number, cc: number, ccc: boolean) => void
|
||||
>p : [c: number, cc: number, ccc: boolean]
|
||||
>d(f.funcC(...p)) : void
|
||||
>d : Dispatch<any>
|
||||
>f.funcC(...p) : void
|
||||
>f.funcC : (c: number, cc: number, ccc: boolean) => void
|
||||
>f : { funcA: (a: boolean) => void; funcB: (b: string, bb: string) => void; funcC: (c: number, cc: number, ccc: boolean) => void; }
|
||||
>funcC : (c: number, cc: number, ccc: boolean) => void
|
||||
>...p : number | boolean
|
||||
>p : [c: number, cc: number, ccc: boolean]
|
||||
|
||||
})
|
||||
);
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
//// [bindingPatternContextualTypeDoesNotCauseWidening.ts]
|
||||
declare function pick<O, T extends keyof O>(keys: T[], obj?: O): Pick<O, T>;
|
||||
const _ = pick(['b'], { a: 'a', b: 'b' }); // T: "b"
|
||||
const { } = pick(['b'], { a: 'a', b: 'b' }); // T: "b" | "a" ??? (before fix)
|
||||
|
||||
|
||||
//// [bindingPatternContextualTypeDoesNotCauseWidening.js]
|
||||
var _ = pick(['b'], { a: 'a', b: 'b' }); // T: "b"
|
||||
var _a = pick(['b'], { a: 'a', b: 'b' }); // T: "b" | "a" ??? (before fix)
|
||||
@@ -0,0 +1,25 @@
|
||||
=== tests/cases/compiler/bindingPatternContextualTypeDoesNotCauseWidening.ts ===
|
||||
declare function pick<O, T extends keyof O>(keys: T[], obj?: O): Pick<O, T>;
|
||||
>pick : Symbol(pick, Decl(bindingPatternContextualTypeDoesNotCauseWidening.ts, 0, 0))
|
||||
>O : Symbol(O, Decl(bindingPatternContextualTypeDoesNotCauseWidening.ts, 0, 22))
|
||||
>T : Symbol(T, Decl(bindingPatternContextualTypeDoesNotCauseWidening.ts, 0, 24))
|
||||
>O : Symbol(O, Decl(bindingPatternContextualTypeDoesNotCauseWidening.ts, 0, 22))
|
||||
>keys : Symbol(keys, Decl(bindingPatternContextualTypeDoesNotCauseWidening.ts, 0, 44))
|
||||
>T : Symbol(T, Decl(bindingPatternContextualTypeDoesNotCauseWidening.ts, 0, 24))
|
||||
>obj : Symbol(obj, Decl(bindingPatternContextualTypeDoesNotCauseWidening.ts, 0, 54))
|
||||
>O : Symbol(O, Decl(bindingPatternContextualTypeDoesNotCauseWidening.ts, 0, 22))
|
||||
>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --))
|
||||
>O : Symbol(O, Decl(bindingPatternContextualTypeDoesNotCauseWidening.ts, 0, 22))
|
||||
>T : Symbol(T, Decl(bindingPatternContextualTypeDoesNotCauseWidening.ts, 0, 24))
|
||||
|
||||
const _ = pick(['b'], { a: 'a', b: 'b' }); // T: "b"
|
||||
>_ : Symbol(_, Decl(bindingPatternContextualTypeDoesNotCauseWidening.ts, 1, 5))
|
||||
>pick : Symbol(pick, Decl(bindingPatternContextualTypeDoesNotCauseWidening.ts, 0, 0))
|
||||
>a : Symbol(a, Decl(bindingPatternContextualTypeDoesNotCauseWidening.ts, 1, 26))
|
||||
>b : Symbol(b, Decl(bindingPatternContextualTypeDoesNotCauseWidening.ts, 1, 34))
|
||||
|
||||
const { } = pick(['b'], { a: 'a', b: 'b' }); // T: "b" | "a" ??? (before fix)
|
||||
>pick : Symbol(pick, Decl(bindingPatternContextualTypeDoesNotCauseWidening.ts, 0, 0))
|
||||
>a : Symbol(a, Decl(bindingPatternContextualTypeDoesNotCauseWidening.ts, 2, 26))
|
||||
>b : Symbol(b, Decl(bindingPatternContextualTypeDoesNotCauseWidening.ts, 2, 34))
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
=== tests/cases/compiler/bindingPatternContextualTypeDoesNotCauseWidening.ts ===
|
||||
declare function pick<O, T extends keyof O>(keys: T[], obj?: O): Pick<O, T>;
|
||||
>pick : <O, T extends keyof O>(keys: T[], obj?: O) => Pick<O, T>
|
||||
>keys : T[]
|
||||
>obj : O
|
||||
|
||||
const _ = pick(['b'], { a: 'a', b: 'b' }); // T: "b"
|
||||
>_ : Pick<{ a: string; b: string; }, "b">
|
||||
>pick(['b'], { a: 'a', b: 'b' }) : Pick<{ a: string; b: string; }, "b">
|
||||
>pick : <O, T extends keyof O>(keys: T[], obj?: O) => Pick<O, T>
|
||||
>['b'] : "b"[]
|
||||
>'b' : "b"
|
||||
>{ a: 'a', b: 'b' } : { a: string; b: string; }
|
||||
>a : string
|
||||
>'a' : "a"
|
||||
>b : string
|
||||
>'b' : "b"
|
||||
|
||||
const { } = pick(['b'], { a: 'a', b: 'b' }); // T: "b" | "a" ??? (before fix)
|
||||
>pick(['b'], { a: 'a', b: 'b' }) : Pick<{ a: string; b: string; }, "b">
|
||||
>pick : <O, T extends keyof O>(keys: T[], obj?: O) => Pick<O, T>
|
||||
>['b'] : "b"[]
|
||||
>'b' : "b"
|
||||
>{ a: 'a', b: 'b' } : { a: string; b: string; }
|
||||
>a : string
|
||||
>'a' : "a"
|
||||
>b : string
|
||||
>'b' : "b"
|
||||
|
||||
@@ -4223,6 +4223,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeError",
|
||||
"kind": "var",
|
||||
@@ -11284,6 +11296,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeError",
|
||||
"kind": "var",
|
||||
@@ -16098,6 +16122,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeError",
|
||||
"kind": "var",
|
||||
@@ -23159,6 +23195,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeError",
|
||||
"kind": "var",
|
||||
@@ -27224,6 +27272,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeError",
|
||||
"kind": "var",
|
||||
@@ -32445,6 +32505,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeError",
|
||||
"kind": "var",
|
||||
@@ -36464,6 +36536,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeError",
|
||||
"kind": "var",
|
||||
@@ -41639,6 +41723,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeError",
|
||||
"kind": "var",
|
||||
@@ -46860,6 +46956,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeError",
|
||||
"kind": "var",
|
||||
@@ -52081,6 +52189,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeError",
|
||||
"kind": "var",
|
||||
@@ -57302,6 +57422,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeError",
|
||||
"kind": "var",
|
||||
@@ -61362,6 +61494,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeError",
|
||||
"kind": "var",
|
||||
@@ -65422,6 +65566,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeError",
|
||||
"kind": "var",
|
||||
@@ -69482,6 +69638,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeError",
|
||||
"kind": "var",
|
||||
@@ -73542,6 +73710,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeError",
|
||||
"kind": "var",
|
||||
@@ -77602,6 +77782,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeError",
|
||||
"kind": "var",
|
||||
@@ -81662,6 +81854,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeError",
|
||||
"kind": "var",
|
||||
@@ -96035,6 +96239,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeError",
|
||||
"kind": "var",
|
||||
|
||||
@@ -5057,6 +5057,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeError",
|
||||
"kind": "var",
|
||||
@@ -11349,6 +11361,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeError",
|
||||
"kind": "var",
|
||||
@@ -17125,6 +17149,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeError",
|
||||
"kind": "var",
|
||||
@@ -28569,6 +28605,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeError",
|
||||
"kind": "var",
|
||||
@@ -34861,6 +34909,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeError",
|
||||
"kind": "var",
|
||||
|
||||
@@ -3568,6 +3568,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeError",
|
||||
"kind": "var",
|
||||
@@ -7197,6 +7209,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeError",
|
||||
"kind": "var",
|
||||
@@ -11356,6 +11380,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeError",
|
||||
"kind": "var",
|
||||
|
||||
@@ -11647,6 +11647,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeError",
|
||||
"kind": "var",
|
||||
@@ -15990,6 +16002,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"kind": "keyword",
|
||||
"kindModifiers": "",
|
||||
"sortText": "15",
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "type",
|
||||
"kind": "keyword"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TypeError",
|
||||
"kind": "var",
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
tests/cases/compiler/declarationEmitDestructuring4.ts(9,22): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/declarationEmitDestructuring4.ts (1 errors) ====
|
||||
// For an array binding pattern with empty elements,
|
||||
// we will not make any modification and will emit
|
||||
// the similar binding pattern users' have written
|
||||
function baz([]) { }
|
||||
function baz1([] = [1,2,3]) { }
|
||||
function baz2([[]] = [[1,2,3]]) { }
|
||||
|
||||
function baz3({}) { }
|
||||
function baz4({} = { x: 10 }) { }
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'.
|
||||
|
||||
|
||||
+1
-7
@@ -1,17 +1,11 @@
|
||||
tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts(1,13): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'.
|
||||
tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts(1,19): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'.
|
||||
tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts(2,23): error TS2353: Object literal may only specify known properties, and 'y4' does not exist in type '{ x4: any; }'.
|
||||
tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts(3,16): error TS2353: Object literal may only specify known properties, and 'x5' does not exist in type '{ y5: any; }'.
|
||||
tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts(5,27): error TS2353: Object literal may only specify known properties, and 'y7' does not exist in type '{ x7: any; }'.
|
||||
tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts(6,20): error TS2353: Object literal may only specify known properties, and 'x8' does not exist in type '{ y8: any; }'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts (6 errors) ====
|
||||
==== tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts (4 errors) ====
|
||||
var { } = { x: 5, y: "hello" };
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'.
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'.
|
||||
var { x4 } = { x4: 5, y4: "hello" };
|
||||
~~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'y4' does not exist in type '{ x4: any; }'.
|
||||
|
||||
+1
-7
@@ -1,17 +1,11 @@
|
||||
tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts(1,13): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'.
|
||||
tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts(1,19): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'.
|
||||
tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts(2,23): error TS2353: Object literal may only specify known properties, and 'y4' does not exist in type '{ x4: any; }'.
|
||||
tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts(3,16): error TS2353: Object literal may only specify known properties, and 'x5' does not exist in type '{ y5: any; }'.
|
||||
tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts(5,27): error TS2353: Object literal may only specify known properties, and 'y7' does not exist in type '{ x7: any; }'.
|
||||
tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts(6,20): error TS2353: Object literal may only specify known properties, and 'x8' does not exist in type '{ y8: any; }'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts (6 errors) ====
|
||||
==== tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts (4 errors) ====
|
||||
var { } = { x: 5, y: "hello" };
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'.
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'.
|
||||
var { x4 } = { x4: 5, y4: "hello" };
|
||||
~~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'y4' does not exist in type '{ x4: any; }'.
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(5,16): error TS2493: Tuple type '[number, string]' of length '2' has no element at index '2'.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(22,17): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(22,23): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(23,25): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(24,19): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(28,28): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'.
|
||||
@@ -22,7 +20,7 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,6):
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts (22 errors) ====
|
||||
==== tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts (20 errors) ====
|
||||
function f0() {
|
||||
var [] = [1, "hello"];
|
||||
var [x] = [1, "hello"];
|
||||
@@ -46,11 +44,7 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9):
|
||||
}
|
||||
|
||||
function f2() {
|
||||
var { } = { x: 5, y: "hello" }; // Error, no x and y in target
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'.
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'.
|
||||
var { } = { x: 5, y: "hello" }; // Ok, empty binding pattern means nothing
|
||||
var { x } = { x: 5, y: "hello" }; // Error, no y in target
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'.
|
||||
|
||||
@@ -20,7 +20,7 @@ function f1() {
|
||||
}
|
||||
|
||||
function f2() {
|
||||
var { } = { x: 5, y: "hello" }; // Error, no x and y in target
|
||||
var { } = { x: 5, y: "hello" }; // Ok, empty binding pattern means nothing
|
||||
var { x } = { x: 5, y: "hello" }; // Error, no y in target
|
||||
var { y } = { x: 5, y: "hello" }; // Error, no x in target
|
||||
var { x, y } = { x: 5, y: "hello" };
|
||||
@@ -206,7 +206,7 @@ function f1() {
|
||||
var z;
|
||||
}
|
||||
function f2() {
|
||||
var _a = { x: 5, y: "hello" }; // Error, no x and y in target
|
||||
var _a = { x: 5, y: "hello" }; // Ok, empty binding pattern means nothing
|
||||
var x = { x: 5, y: "hello" }.x; // Error, no y in target
|
||||
var y = { x: 5, y: "hello" }.y; // Error, no x in target
|
||||
var _b = { x: 5, y: "hello" }, x = _b.x, y = _b.y;
|
||||
|
||||
@@ -59,7 +59,7 @@ function f1() {
|
||||
function f2() {
|
||||
>f2 : Symbol(f2, Decl(declarationsAndAssignments.ts, 18, 1))
|
||||
|
||||
var { } = { x: 5, y: "hello" }; // Error, no x and y in target
|
||||
var { } = { x: 5, y: "hello" }; // Ok, empty binding pattern means nothing
|
||||
>x : Symbol(x, Decl(declarationsAndAssignments.ts, 21, 15))
|
||||
>y : Symbol(y, Decl(declarationsAndAssignments.ts, 21, 21))
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ function f1() {
|
||||
function f2() {
|
||||
>f2 : () => void
|
||||
|
||||
var { } = { x: 5, y: "hello" }; // Error, no x and y in target
|
||||
var { } = { x: 5, y: "hello" }; // Ok, empty binding pattern means nothing
|
||||
>{ x: 5, y: "hello" } : { x: number; y: string; }
|
||||
>x : number
|
||||
>5 : 5
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts(1,18): error TS2353: Object literal may only specify known properties, and 'a' does not exist in type '{}'.
|
||||
tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts(1,24): error TS2353: Object literal may only specify known properties, and 'b' does not exist in type '{}'.
|
||||
tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts(1,32): error TS2353: Object literal may only specify known properties, and 'c' does not exist in type '{}'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts (3 errors) ====
|
||||
function f({} = {a: 1, b: "2", c: true}) {
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'a' does not exist in type '{}'.
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'b' does not exist in type '{}'.
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'c' does not exist in type '{}'.
|
||||
var x, y, z;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
//// [inferTupleFromBindingPattern.ts]
|
||||
declare function f<T>(cb: () => T): T;
|
||||
const [e1, e2, e3] = f(() => [1, "hi", true]);
|
||||
|
||||
|
||||
//// [inferTupleFromBindingPattern.js]
|
||||
var _a = f(function () { return [1, "hi", true]; }), e1 = _a[0], e2 = _a[1], e3 = _a[2];
|
||||
@@ -0,0 +1,14 @@
|
||||
=== tests/cases/compiler/inferTupleFromBindingPattern.ts ===
|
||||
declare function f<T>(cb: () => T): T;
|
||||
>f : Symbol(f, Decl(inferTupleFromBindingPattern.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(inferTupleFromBindingPattern.ts, 0, 19))
|
||||
>cb : Symbol(cb, Decl(inferTupleFromBindingPattern.ts, 0, 22))
|
||||
>T : Symbol(T, Decl(inferTupleFromBindingPattern.ts, 0, 19))
|
||||
>T : Symbol(T, Decl(inferTupleFromBindingPattern.ts, 0, 19))
|
||||
|
||||
const [e1, e2, e3] = f(() => [1, "hi", true]);
|
||||
>e1 : Symbol(e1, Decl(inferTupleFromBindingPattern.ts, 1, 7))
|
||||
>e2 : Symbol(e2, Decl(inferTupleFromBindingPattern.ts, 1, 10))
|
||||
>e3 : Symbol(e3, Decl(inferTupleFromBindingPattern.ts, 1, 14))
|
||||
>f : Symbol(f, Decl(inferTupleFromBindingPattern.ts, 0, 0))
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/compiler/inferTupleFromBindingPattern.ts ===
|
||||
declare function f<T>(cb: () => T): T;
|
||||
>f : <T>(cb: () => T) => T
|
||||
>cb : () => T
|
||||
|
||||
const [e1, e2, e3] = f(() => [1, "hi", true]);
|
||||
>e1 : number
|
||||
>e2 : string
|
||||
>e3 : boolean
|
||||
>f(() => [1, "hi", true]) : [number, string, boolean]
|
||||
>f : <T>(cb: () => T) => T
|
||||
>() => [1, "hi", true] : () => [number, string, boolean]
|
||||
>[1, "hi", true] : [number, string, true]
|
||||
>1 : 1
|
||||
>"hi" : "hi"
|
||||
>true : true
|
||||
|
||||
@@ -10,8 +10,6 @@ tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(12,8): e
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(12,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(13,18): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(14,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(20,17): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(20,23): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(21,25): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(22,19): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(29,14): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'.
|
||||
@@ -20,7 +18,7 @@ tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(30,22):
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(31,16): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: number; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts (20 errors) ====
|
||||
==== tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts (18 errors) ====
|
||||
// Missing properties
|
||||
function f1() {
|
||||
var { x, y } = {};
|
||||
@@ -69,10 +67,6 @@ tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(31,16):
|
||||
// Excess properties
|
||||
function f3() {
|
||||
var { } = { x: 0, y: 0 };
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'.
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'.
|
||||
var { x } = { x: 0, y: 0 };
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'.
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
//// [tests/cases/compiler/moduleNodeImportRequireEmit.ts] ////
|
||||
|
||||
//// [package.json]
|
||||
{
|
||||
"type": "module"
|
||||
}
|
||||
//// [mod.d.ts]
|
||||
declare module "foo";
|
||||
//// [index.ts]
|
||||
/// <reference path="./mod.d.ts" />
|
||||
// This should emit a call to createRequire(import.meta.url)
|
||||
import foo = require("foo");
|
||||
foo;
|
||||
|
||||
//// [index.js]
|
||||
import { createRequire as _createRequire } from "module";
|
||||
const __require = _createRequire(import.meta.url);
|
||||
/// <reference path="./mod.d.ts" />
|
||||
// This should emit a call to createRequire(import.meta.url)
|
||||
const foo = __require("foo");
|
||||
foo;
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/index.ts ===
|
||||
/// <reference path="./mod.d.ts" />
|
||||
// This should emit a call to createRequire(import.meta.url)
|
||||
import foo = require("foo");
|
||||
>foo : Symbol(foo, Decl(index.ts, 0, 0))
|
||||
|
||||
foo;
|
||||
>foo : Symbol(foo, Decl(index.ts, 0, 0))
|
||||
|
||||
=== tests/cases/compiler/mod.d.ts ===
|
||||
declare module "foo";
|
||||
>"foo" : Symbol("foo", Decl(mod.d.ts, 0, 0))
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/index.ts ===
|
||||
/// <reference path="./mod.d.ts" />
|
||||
// This should emit a call to createRequire(import.meta.url)
|
||||
import foo = require("foo");
|
||||
>foo : any
|
||||
|
||||
foo;
|
||||
>foo : any
|
||||
|
||||
=== tests/cases/compiler/mod.d.ts ===
|
||||
declare module "foo";
|
||||
>"foo" : any
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
//// [tests/cases/compiler/moduleNodeImportRequireEmit.ts] ////
|
||||
|
||||
//// [package.json]
|
||||
{
|
||||
"type": "module"
|
||||
}
|
||||
//// [mod.d.ts]
|
||||
declare module "foo";
|
||||
//// [index.ts]
|
||||
/// <reference path="./mod.d.ts" />
|
||||
// This should emit a call to createRequire(import.meta.url)
|
||||
import foo = require("foo");
|
||||
foo;
|
||||
|
||||
//// [index.js]
|
||||
import { createRequire as _createRequire } from "module";
|
||||
const __require = _createRequire(import.meta.url);
|
||||
/// <reference path="./mod.d.ts" />
|
||||
// This should emit a call to createRequire(import.meta.url)
|
||||
const foo = __require("foo");
|
||||
foo;
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/index.ts ===
|
||||
/// <reference path="./mod.d.ts" />
|
||||
// This should emit a call to createRequire(import.meta.url)
|
||||
import foo = require("foo");
|
||||
>foo : Symbol(foo, Decl(index.ts, 0, 0))
|
||||
|
||||
foo;
|
||||
>foo : Symbol(foo, Decl(index.ts, 0, 0))
|
||||
|
||||
=== tests/cases/compiler/mod.d.ts ===
|
||||
declare module "foo";
|
||||
>"foo" : Symbol("foo", Decl(mod.d.ts, 0, 0))
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/index.ts ===
|
||||
/// <reference path="./mod.d.ts" />
|
||||
// This should emit a call to createRequire(import.meta.url)
|
||||
import foo = require("foo");
|
||||
>foo : any
|
||||
|
||||
foo;
|
||||
>foo : any
|
||||
|
||||
=== tests/cases/compiler/mod.d.ts ===
|
||||
declare module "foo";
|
||||
>"foo" : any
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
//// [tests/cases/compiler/moduleNodeImportRequireEmit.ts] ////
|
||||
|
||||
//// [package.json]
|
||||
{
|
||||
"type": "module"
|
||||
}
|
||||
//// [mod.d.ts]
|
||||
declare module "foo";
|
||||
//// [index.ts]
|
||||
/// <reference path="./mod.d.ts" />
|
||||
// This should emit a call to createRequire(import.meta.url)
|
||||
import foo = require("foo");
|
||||
foo;
|
||||
|
||||
//// [index.js]
|
||||
import { createRequire as _createRequire } from "module";
|
||||
var __require = _createRequire(import.meta.url);
|
||||
/// <reference path="./mod.d.ts" />
|
||||
// This should emit a call to createRequire(import.meta.url)
|
||||
var foo = __require("foo");
|
||||
foo;
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/index.ts ===
|
||||
/// <reference path="./mod.d.ts" />
|
||||
// This should emit a call to createRequire(import.meta.url)
|
||||
import foo = require("foo");
|
||||
>foo : Symbol(foo, Decl(index.ts, 0, 0))
|
||||
|
||||
foo;
|
||||
>foo : Symbol(foo, Decl(index.ts, 0, 0))
|
||||
|
||||
=== tests/cases/compiler/mod.d.ts ===
|
||||
declare module "foo";
|
||||
>"foo" : Symbol("foo", Decl(mod.d.ts, 0, 0))
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/index.ts ===
|
||||
/// <reference path="./mod.d.ts" />
|
||||
// This should emit a call to createRequire(import.meta.url)
|
||||
import foo = require("foo");
|
||||
>foo : any
|
||||
|
||||
foo;
|
||||
>foo : any
|
||||
|
||||
=== tests/cases/compiler/mod.d.ts ===
|
||||
declare module "foo";
|
||||
>"foo" : any
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
//// [tests/cases/compiler/moduleNodeImportRequireEmit.ts] ////
|
||||
|
||||
//// [package.json]
|
||||
{
|
||||
"type": "module"
|
||||
}
|
||||
//// [mod.d.ts]
|
||||
declare module "foo";
|
||||
//// [index.ts]
|
||||
/// <reference path="./mod.d.ts" />
|
||||
// This should emit a call to createRequire(import.meta.url)
|
||||
import foo = require("foo");
|
||||
foo;
|
||||
|
||||
//// [index.js]
|
||||
import { createRequire as _createRequire } from "module";
|
||||
const __require = _createRequire(import.meta.url);
|
||||
/// <reference path="./mod.d.ts" />
|
||||
// This should emit a call to createRequire(import.meta.url)
|
||||
const foo = __require("foo");
|
||||
foo;
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/index.ts ===
|
||||
/// <reference path="./mod.d.ts" />
|
||||
// This should emit a call to createRequire(import.meta.url)
|
||||
import foo = require("foo");
|
||||
>foo : Symbol(foo, Decl(index.ts, 0, 0))
|
||||
|
||||
foo;
|
||||
>foo : Symbol(foo, Decl(index.ts, 0, 0))
|
||||
|
||||
=== tests/cases/compiler/mod.d.ts ===
|
||||
declare module "foo";
|
||||
>"foo" : Symbol("foo", Decl(mod.d.ts, 0, 0))
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/index.ts ===
|
||||
/// <reference path="./mod.d.ts" />
|
||||
// This should emit a call to createRequire(import.meta.url)
|
||||
import foo = require("foo");
|
||||
>foo : any
|
||||
|
||||
foo;
|
||||
>foo : any
|
||||
|
||||
=== tests/cases/compiler/mod.d.ts ===
|
||||
declare module "foo";
|
||||
>"foo" : any
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
//// [objectBindingPatternContextuallyTypesArgument.ts]
|
||||
declare function id<T>(x: T): T;
|
||||
const { f = (x: string) => x.length } = id({ f: x => x.charAt });
|
||||
|
||||
|
||||
//// [objectBindingPatternContextuallyTypesArgument.js]
|
||||
var _a = id({ f: function (x) { return x.charAt; } }).f, f = _a === void 0 ? function (x) { return x.length; } : _a;
|
||||
@@ -0,0 +1,21 @@
|
||||
=== tests/cases/compiler/objectBindingPatternContextuallyTypesArgument.ts ===
|
||||
declare function id<T>(x: T): T;
|
||||
>id : Symbol(id, Decl(objectBindingPatternContextuallyTypesArgument.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(objectBindingPatternContextuallyTypesArgument.ts, 0, 20))
|
||||
>x : Symbol(x, Decl(objectBindingPatternContextuallyTypesArgument.ts, 0, 23))
|
||||
>T : Symbol(T, Decl(objectBindingPatternContextuallyTypesArgument.ts, 0, 20))
|
||||
>T : Symbol(T, Decl(objectBindingPatternContextuallyTypesArgument.ts, 0, 20))
|
||||
|
||||
const { f = (x: string) => x.length } = id({ f: x => x.charAt });
|
||||
>f : Symbol(f, Decl(objectBindingPatternContextuallyTypesArgument.ts, 1, 7))
|
||||
>x : Symbol(x, Decl(objectBindingPatternContextuallyTypesArgument.ts, 1, 13))
|
||||
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(objectBindingPatternContextuallyTypesArgument.ts, 1, 13))
|
||||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>id : Symbol(id, Decl(objectBindingPatternContextuallyTypesArgument.ts, 0, 0))
|
||||
>f : Symbol(f, Decl(objectBindingPatternContextuallyTypesArgument.ts, 1, 44))
|
||||
>x : Symbol(x, Decl(objectBindingPatternContextuallyTypesArgument.ts, 1, 47))
|
||||
>x.charAt : Symbol(String.charAt, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(objectBindingPatternContextuallyTypesArgument.ts, 1, 47))
|
||||
>charAt : Symbol(String.charAt, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
=== tests/cases/compiler/objectBindingPatternContextuallyTypesArgument.ts ===
|
||||
declare function id<T>(x: T): T;
|
||||
>id : <T>(x: T) => T
|
||||
>x : T
|
||||
|
||||
const { f = (x: string) => x.length } = id({ f: x => x.charAt });
|
||||
>f : ((x: string) => number) | ((x: string) => (pos: number) => string)
|
||||
>(x: string) => x.length : (x: string) => number
|
||||
>x : string
|
||||
>x.length : number
|
||||
>x : string
|
||||
>length : number
|
||||
>id({ f: x => x.charAt }) : { f: (x: string) => (pos: number) => string; }
|
||||
>id : <T>(x: T) => T
|
||||
>{ f: x => x.charAt } : { f: (x: string) => (pos: number) => string; }
|
||||
>f : (x: string) => (pos: number) => string
|
||||
>x => x.charAt : (x: string) => (pos: number) => string
|
||||
>x : string
|
||||
>x.charAt : (pos: number) => string
|
||||
>x : string
|
||||
>charAt : (pos: number) => string
|
||||
|
||||
+388
@@ -0,0 +1,388 @@
|
||||
Input::
|
||||
//// [/user/username/projects/myproject/f1.ts]
|
||||
export const x = 1
|
||||
|
||||
//// [/user/username/projects/myproject/f2.ts]
|
||||
export const y = 1
|
||||
|
||||
//// [/a/lib/lib.d.ts]
|
||||
/// <reference no-default-lib="true"/>
|
||||
interface Boolean {}
|
||||
interface Function {}
|
||||
interface CallableFunction {}
|
||||
interface NewableFunction {}
|
||||
interface IArguments {}
|
||||
interface Number { toExponential: any; }
|
||||
interface Object {}
|
||||
interface RegExp {}
|
||||
interface String { charAt: any; }
|
||||
interface Array<T> { length: number; [n: number]: T; }
|
||||
|
||||
//// [/user/username/projects/myproject/tsconfig.json]
|
||||
{"compilerOptions":{"composite":true},"include":["./","./**/*.json"]}
|
||||
|
||||
|
||||
/a/lib/tsc.js -w --extendedDiagnostics
|
||||
Output::
|
||||
[[90m12:00:23 AM[0m] Starting compilation in watch mode...
|
||||
|
||||
Current directory: /user/username/projects/myproject CaseSensitiveFileNames: false
|
||||
FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Config file
|
||||
Synchronizing program
|
||||
CreatingProgramWith::
|
||||
roots: ["/user/username/projects/myproject/f1.ts","/user/username/projects/myproject/f2.ts"]
|
||||
options: {"composite":true,"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
|
||||
FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/f1.ts 250 undefined Source file
|
||||
FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/f2.ts 250 undefined Source file
|
||||
FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 undefined Source file
|
||||
DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 undefined Type roots
|
||||
Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 undefined Type roots
|
||||
[[90m12:00:34 AM[0m] Found 0 errors. Watching for file changes.
|
||||
|
||||
DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 undefined Wild card directory
|
||||
Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 undefined Wild card directory
|
||||
|
||||
|
||||
Program root files: ["/user/username/projects/myproject/f1.ts","/user/username/projects/myproject/f2.ts"]
|
||||
Program options: {"composite":true,"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
|
||||
Program structureReused: Not
|
||||
Program files::
|
||||
/a/lib/lib.d.ts
|
||||
/user/username/projects/myproject/f1.ts
|
||||
/user/username/projects/myproject/f2.ts
|
||||
|
||||
Semantic diagnostics in builder refreshed for::
|
||||
/a/lib/lib.d.ts
|
||||
/user/username/projects/myproject/f1.ts
|
||||
/user/username/projects/myproject/f2.ts
|
||||
|
||||
Shape signatures in builder refreshed for::
|
||||
/a/lib/lib.d.ts (used version)
|
||||
/user/username/projects/myproject/f1.ts (computed .d.ts during emit)
|
||||
/user/username/projects/myproject/f2.ts (computed .d.ts during emit)
|
||||
|
||||
WatchedFiles::
|
||||
/user/username/projects/myproject/tsconfig.json:
|
||||
{"fileName":"/user/username/projects/myproject/tsconfig.json","pollingInterval":250}
|
||||
/user/username/projects/myproject/f1.ts:
|
||||
{"fileName":"/user/username/projects/myproject/f1.ts","pollingInterval":250}
|
||||
/user/username/projects/myproject/f2.ts:
|
||||
{"fileName":"/user/username/projects/myproject/f2.ts","pollingInterval":250}
|
||||
/a/lib/lib.d.ts:
|
||||
{"fileName":"/a/lib/lib.d.ts","pollingInterval":250}
|
||||
/user/username/projects/myproject/node_modules/@types:
|
||||
{"fileName":"/user/username/projects/myproject/node_modules/@types","pollingInterval":500}
|
||||
|
||||
FsWatches::
|
||||
|
||||
FsWatchesRecursive::
|
||||
/user/username/projects/myproject:
|
||||
{"directoryName":"/user/username/projects/myproject"}
|
||||
|
||||
exitCode:: ExitStatus.undefined
|
||||
|
||||
//// [/user/username/projects/myproject/f1.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.x = void 0;
|
||||
exports.x = 1;
|
||||
|
||||
|
||||
//// [/user/username/projects/myproject/f1.d.ts]
|
||||
export declare const x = 1;
|
||||
|
||||
|
||||
//// [/user/username/projects/myproject/f2.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.y = void 0;
|
||||
exports.y = 1;
|
||||
|
||||
|
||||
//// [/user/username/projects/myproject/f2.d.ts]
|
||||
export declare const y = 1;
|
||||
|
||||
|
||||
//// [/user/username/projects/myproject/tsconfig.tsbuildinfo]
|
||||
{"program":{"fileNames":["../../../../a/lib/lib.d.ts","./f1.ts","./f2.ts"],"fileInfos":[{"version":"-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }","affectsGlobalScope":true},{"version":"-10906998252-export const x = 1","signature":"-7495133367-export declare const x = 1;\n"},{"version":"-10905812331-export const y = 1","signature":"-6203665398-export declare const y = 1;\n"}],"options":{"composite":true},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"}
|
||||
|
||||
//// [/user/username/projects/myproject/tsconfig.tsbuildinfo.readable.baseline.txt]
|
||||
{
|
||||
"program": {
|
||||
"fileNames": [
|
||||
"../../../../a/lib/lib.d.ts",
|
||||
"./f1.ts",
|
||||
"./f2.ts"
|
||||
],
|
||||
"fileInfos": {
|
||||
"../../../../a/lib/lib.d.ts": {
|
||||
"version": "-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }",
|
||||
"signature": "-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }",
|
||||
"affectsGlobalScope": true
|
||||
},
|
||||
"./f1.ts": {
|
||||
"version": "-10906998252-export const x = 1",
|
||||
"signature": "-7495133367-export declare const x = 1;\n"
|
||||
},
|
||||
"./f2.ts": {
|
||||
"version": "-10905812331-export const y = 1",
|
||||
"signature": "-6203665398-export declare const y = 1;\n"
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
"composite": true
|
||||
},
|
||||
"referencedMap": {},
|
||||
"exportedModulesMap": {},
|
||||
"semanticDiagnosticsPerFile": [
|
||||
"../../../../a/lib/lib.d.ts",
|
||||
"./f1.ts",
|
||||
"./f2.ts"
|
||||
]
|
||||
},
|
||||
"version": "FakeTSVersion",
|
||||
"size": 828
|
||||
}
|
||||
|
||||
|
||||
Change:: Add new file
|
||||
|
||||
Input::
|
||||
//// [/user/username/projects/myproject/new-file.ts]
|
||||
export const z = 1;
|
||||
|
||||
|
||||
Output::
|
||||
DirectoryWatcher:: Triggered with /user/username/projects/myproject/new-file.ts :: WatchInfo: /user/username/projects/myproject 1 undefined Wild card directory
|
||||
Scheduling update
|
||||
Elapsed:: *ms DirectoryWatcher:: Triggered with /user/username/projects/myproject/new-file.ts :: WatchInfo: /user/username/projects/myproject 1 undefined Wild card directory
|
||||
Reloading new file names and options
|
||||
Synchronizing program
|
||||
[[90m12:00:39 AM[0m] File change detected. Starting incremental compilation...
|
||||
|
||||
CreatingProgramWith::
|
||||
roots: ["/user/username/projects/myproject/f1.ts","/user/username/projects/myproject/f2.ts","/user/username/projects/myproject/new-file.ts"]
|
||||
options: {"composite":true,"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
|
||||
FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/new-file.ts 250 undefined Source file
|
||||
DirectoryWatcher:: Triggered with /user/username/projects/myproject/new-file.js :: WatchInfo: /user/username/projects/myproject 1 undefined Wild card directory
|
||||
Project: /user/username/projects/myproject/tsconfig.json Detected file add/remove of non supported extension: /user/username/projects/myproject/new-file.js
|
||||
Elapsed:: *ms DirectoryWatcher:: Triggered with /user/username/projects/myproject/new-file.js :: WatchInfo: /user/username/projects/myproject 1 undefined Wild card directory
|
||||
DirectoryWatcher:: Triggered with /user/username/projects/myproject/new-file.d.ts :: WatchInfo: /user/username/projects/myproject 1 undefined Wild card directory
|
||||
Project: /user/username/projects/myproject/tsconfig.json Detected output file: /user/username/projects/myproject/new-file.d.ts
|
||||
Elapsed:: *ms DirectoryWatcher:: Triggered with /user/username/projects/myproject/new-file.d.ts :: WatchInfo: /user/username/projects/myproject 1 undefined Wild card directory
|
||||
[[90m12:00:47 AM[0m] Found 0 errors. Watching for file changes.
|
||||
|
||||
|
||||
|
||||
Program root files: ["/user/username/projects/myproject/f1.ts","/user/username/projects/myproject/f2.ts","/user/username/projects/myproject/new-file.ts"]
|
||||
Program options: {"composite":true,"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
|
||||
Program structureReused: Not
|
||||
Program files::
|
||||
/a/lib/lib.d.ts
|
||||
/user/username/projects/myproject/f1.ts
|
||||
/user/username/projects/myproject/f2.ts
|
||||
/user/username/projects/myproject/new-file.ts
|
||||
|
||||
Semantic diagnostics in builder refreshed for::
|
||||
/user/username/projects/myproject/new-file.ts
|
||||
|
||||
Shape signatures in builder refreshed for::
|
||||
/user/username/projects/myproject/new-file.ts (computed .d.ts)
|
||||
|
||||
WatchedFiles::
|
||||
/user/username/projects/myproject/tsconfig.json:
|
||||
{"fileName":"/user/username/projects/myproject/tsconfig.json","pollingInterval":250}
|
||||
/user/username/projects/myproject/f1.ts:
|
||||
{"fileName":"/user/username/projects/myproject/f1.ts","pollingInterval":250}
|
||||
/user/username/projects/myproject/f2.ts:
|
||||
{"fileName":"/user/username/projects/myproject/f2.ts","pollingInterval":250}
|
||||
/a/lib/lib.d.ts:
|
||||
{"fileName":"/a/lib/lib.d.ts","pollingInterval":250}
|
||||
/user/username/projects/myproject/node_modules/@types:
|
||||
{"fileName":"/user/username/projects/myproject/node_modules/@types","pollingInterval":500}
|
||||
/user/username/projects/myproject/new-file.ts:
|
||||
{"fileName":"/user/username/projects/myproject/new-file.ts","pollingInterval":250}
|
||||
|
||||
FsWatches::
|
||||
|
||||
FsWatchesRecursive::
|
||||
/user/username/projects/myproject:
|
||||
{"directoryName":"/user/username/projects/myproject"}
|
||||
|
||||
exitCode:: ExitStatus.undefined
|
||||
|
||||
//// [/user/username/projects/myproject/tsconfig.tsbuildinfo]
|
||||
{"program":{"fileNames":["../../../../a/lib/lib.d.ts","./f1.ts","./f2.ts","./new-file.ts"],"fileInfos":[{"version":"-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }","affectsGlobalScope":true},{"version":"-10906998252-export const x = 1","signature":"-7495133367-export declare const x = 1;\n"},{"version":"-10905812331-export const y = 1","signature":"-6203665398-export declare const y = 1;\n"},{"version":"-11960320495-export const z = 1;","signature":"-9207164725-export declare const z = 1;\n"}],"options":{"composite":true},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3,4]},"version":"FakeTSVersion"}
|
||||
|
||||
//// [/user/username/projects/myproject/tsconfig.tsbuildinfo.readable.baseline.txt]
|
||||
{
|
||||
"program": {
|
||||
"fileNames": [
|
||||
"../../../../a/lib/lib.d.ts",
|
||||
"./f1.ts",
|
||||
"./f2.ts",
|
||||
"./new-file.ts"
|
||||
],
|
||||
"fileInfos": {
|
||||
"../../../../a/lib/lib.d.ts": {
|
||||
"version": "-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }",
|
||||
"signature": "-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }",
|
||||
"affectsGlobalScope": true
|
||||
},
|
||||
"./f1.ts": {
|
||||
"version": "-10906998252-export const x = 1",
|
||||
"signature": "-7495133367-export declare const x = 1;\n"
|
||||
},
|
||||
"./f2.ts": {
|
||||
"version": "-10905812331-export const y = 1",
|
||||
"signature": "-6203665398-export declare const y = 1;\n"
|
||||
},
|
||||
"./new-file.ts": {
|
||||
"version": "-11960320495-export const z = 1;",
|
||||
"signature": "-9207164725-export declare const z = 1;\n"
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
"composite": true
|
||||
},
|
||||
"referencedMap": {},
|
||||
"exportedModulesMap": {},
|
||||
"semanticDiagnosticsPerFile": [
|
||||
"../../../../a/lib/lib.d.ts",
|
||||
"./f1.ts",
|
||||
"./f2.ts",
|
||||
"./new-file.ts"
|
||||
]
|
||||
},
|
||||
"version": "FakeTSVersion",
|
||||
"size": 949
|
||||
}
|
||||
|
||||
//// [/user/username/projects/myproject/new-file.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.z = void 0;
|
||||
exports.z = 1;
|
||||
|
||||
|
||||
//// [/user/username/projects/myproject/new-file.d.ts]
|
||||
export declare const z = 1;
|
||||
|
||||
|
||||
|
||||
Change:: Import new file
|
||||
|
||||
Input::
|
||||
//// [/user/username/projects/myproject/f1.ts]
|
||||
import { z } from "./new-file";export const x = 1
|
||||
|
||||
|
||||
Output::
|
||||
FileWatcher:: Triggered with /user/username/projects/myproject/f1.ts 1:: WatchInfo: /user/username/projects/myproject/f1.ts 250 undefined Source file
|
||||
Scheduling update
|
||||
Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/f1.ts 1:: WatchInfo: /user/username/projects/myproject/f1.ts 250 undefined Source file
|
||||
Synchronizing program
|
||||
[[90m12:00:53 AM[0m] File change detected. Starting incremental compilation...
|
||||
|
||||
CreatingProgramWith::
|
||||
roots: ["/user/username/projects/myproject/f1.ts","/user/username/projects/myproject/f2.ts","/user/username/projects/myproject/new-file.ts"]
|
||||
options: {"composite":true,"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
|
||||
[[90m12:01:03 AM[0m] Found 0 errors. Watching for file changes.
|
||||
|
||||
|
||||
|
||||
Program root files: ["/user/username/projects/myproject/f1.ts","/user/username/projects/myproject/f2.ts","/user/username/projects/myproject/new-file.ts"]
|
||||
Program options: {"composite":true,"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
|
||||
Program structureReused: SafeModules
|
||||
Program files::
|
||||
/a/lib/lib.d.ts
|
||||
/user/username/projects/myproject/new-file.ts
|
||||
/user/username/projects/myproject/f1.ts
|
||||
/user/username/projects/myproject/f2.ts
|
||||
|
||||
Semantic diagnostics in builder refreshed for::
|
||||
/user/username/projects/myproject/f1.ts
|
||||
|
||||
Shape signatures in builder refreshed for::
|
||||
/user/username/projects/myproject/f1.ts (computed .d.ts)
|
||||
|
||||
WatchedFiles::
|
||||
/user/username/projects/myproject/tsconfig.json:
|
||||
{"fileName":"/user/username/projects/myproject/tsconfig.json","pollingInterval":250}
|
||||
/user/username/projects/myproject/f1.ts:
|
||||
{"fileName":"/user/username/projects/myproject/f1.ts","pollingInterval":250}
|
||||
/user/username/projects/myproject/f2.ts:
|
||||
{"fileName":"/user/username/projects/myproject/f2.ts","pollingInterval":250}
|
||||
/a/lib/lib.d.ts:
|
||||
{"fileName":"/a/lib/lib.d.ts","pollingInterval":250}
|
||||
/user/username/projects/myproject/node_modules/@types:
|
||||
{"fileName":"/user/username/projects/myproject/node_modules/@types","pollingInterval":500}
|
||||
/user/username/projects/myproject/new-file.ts:
|
||||
{"fileName":"/user/username/projects/myproject/new-file.ts","pollingInterval":250}
|
||||
|
||||
FsWatches::
|
||||
|
||||
FsWatchesRecursive::
|
||||
/user/username/projects/myproject:
|
||||
{"directoryName":"/user/username/projects/myproject"}
|
||||
|
||||
exitCode:: ExitStatus.undefined
|
||||
|
||||
//// [/user/username/projects/myproject/f1.js] file written with same contents
|
||||
//// [/user/username/projects/myproject/f1.d.ts] file written with same contents
|
||||
//// [/user/username/projects/myproject/tsconfig.tsbuildinfo]
|
||||
{"program":{"fileNames":["../../../../a/lib/lib.d.ts","./new-file.ts","./f1.ts","./f2.ts"],"fileInfos":[{"version":"-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }","affectsGlobalScope":true},{"version":"-11960320495-export const z = 1;","signature":"-9207164725-export declare const z = 1;\n"},{"version":"1363236232-import { z } from \"./new-file\";export const x = 1","signature":"-7495133367-export declare const x = 1;\n"},{"version":"-10905812331-export const y = 1","signature":"-6203665398-export declare const y = 1;\n"}],"options":{"composite":true},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,3,4,2]},"version":"FakeTSVersion"}
|
||||
|
||||
//// [/user/username/projects/myproject/tsconfig.tsbuildinfo.readable.baseline.txt]
|
||||
{
|
||||
"program": {
|
||||
"fileNames": [
|
||||
"../../../../a/lib/lib.d.ts",
|
||||
"./new-file.ts",
|
||||
"./f1.ts",
|
||||
"./f2.ts"
|
||||
],
|
||||
"fileNamesList": [
|
||||
[
|
||||
"./new-file.ts"
|
||||
]
|
||||
],
|
||||
"fileInfos": {
|
||||
"../../../../a/lib/lib.d.ts": {
|
||||
"version": "-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }",
|
||||
"signature": "-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }",
|
||||
"affectsGlobalScope": true
|
||||
},
|
||||
"./new-file.ts": {
|
||||
"version": "-11960320495-export const z = 1;",
|
||||
"signature": "-9207164725-export declare const z = 1;\n"
|
||||
},
|
||||
"./f1.ts": {
|
||||
"version": "1363236232-import { z } from \"./new-file\";export const x = 1",
|
||||
"signature": "-7495133367-export declare const x = 1;\n"
|
||||
},
|
||||
"./f2.ts": {
|
||||
"version": "-10905812331-export const y = 1",
|
||||
"signature": "-6203665398-export declare const y = 1;\n"
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
"composite": true
|
||||
},
|
||||
"referencedMap": {
|
||||
"./f1.ts": [
|
||||
"./new-file.ts"
|
||||
]
|
||||
},
|
||||
"exportedModulesMap": {},
|
||||
"semanticDiagnosticsPerFile": [
|
||||
"../../../../a/lib/lib.d.ts",
|
||||
"./f1.ts",
|
||||
"./f2.ts",
|
||||
"./new-file.ts"
|
||||
]
|
||||
},
|
||||
"version": "FakeTSVersion",
|
||||
"size": 1005
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// @strictNullChecks: true
|
||||
|
||||
declare function f<T>(): T;
|
||||
const {} = f(); // error (only in strictNullChecks)
|
||||
const { p1 } = f(); // error
|
||||
const [] = f(); // error
|
||||
const [e1, e2] = f(); // error
|
||||
|
||||
// Repro from #43605
|
||||
type Dispatch<A = { type: any; [extraProps: string]: any }> = { <T extends A>(action: T): T };
|
||||
type IFuncs = { readonly [key: string]: (...p: any) => void };
|
||||
type IDestructuring<T extends IFuncs> = { readonly [key in keyof T]?: (...p: Parameters<T[key]>) => void };
|
||||
type Destructuring<T extends IFuncs, U extends IDestructuring<T>> = (dispatch: Dispatch<any>, funcs: T) => U;
|
||||
const funcs1 = {
|
||||
funcA: (a: boolean): void => {},
|
||||
funcB: (b: string, bb: string): void => {},
|
||||
funcC: (c: number, cc: number, ccc: boolean): void => {},
|
||||
};
|
||||
type TFuncs1 = typeof funcs1;
|
||||
declare function useReduxDispatch1<T extends IDestructuring<TFuncs1>>(destructuring: Destructuring<TFuncs1, T>): T;
|
||||
const {} = useReduxDispatch1(
|
||||
(d, f) => ({
|
||||
funcA: (...p) => d(f.funcA(...p)), // p should be inferrable
|
||||
funcB: (...p) => d(f.funcB(...p)),
|
||||
funcC: (...p) => d(f.funcC(...p)),
|
||||
})
|
||||
);
|
||||
@@ -0,0 +1,3 @@
|
||||
declare function pick<O, T extends keyof O>(keys: T[], obj?: O): Pick<O, T>;
|
||||
const _ = pick(['b'], { a: 'a', b: 'b' }); // T: "b"
|
||||
const { } = pick(['b'], { a: 'a', b: 'b' }); // T: "b" | "a" ??? (before fix)
|
||||
@@ -0,0 +1,2 @@
|
||||
declare function f<T>(cb: () => T): T;
|
||||
const [e1, e2, e3] = f(() => [1, "hi", true]);
|
||||
@@ -0,0 +1,13 @@
|
||||
// @target: es5,es2016,es2020,esnext
|
||||
// @module: nodenext
|
||||
// @filename: package.json
|
||||
{
|
||||
"type": "module"
|
||||
}
|
||||
// @filename: mod.d.ts
|
||||
declare module "foo";
|
||||
// @filename: index.ts
|
||||
/// <reference path="./mod.d.ts" />
|
||||
// This should emit a call to createRequire(import.meta.url)
|
||||
import foo = require("foo");
|
||||
foo;
|
||||
@@ -0,0 +1,2 @@
|
||||
declare function id<T>(x: T): T;
|
||||
const { f = (x: string) => x.length } = id({ f: x => x.charAt });
|
||||
@@ -19,7 +19,7 @@ function f1() {
|
||||
}
|
||||
|
||||
function f2() {
|
||||
var { } = { x: 5, y: "hello" }; // Error, no x and y in target
|
||||
var { } = { x: 5, y: "hello" }; // Ok, empty binding pattern means nothing
|
||||
var { x } = { x: 5, y: "hello" }; // Error, no y in target
|
||||
var { y } = { x: 5, y: "hello" }; // Error, no x in target
|
||||
var { x, y } = { x: 5, y: "hello" };
|
||||
|
||||
@@ -666,6 +666,7 @@ declare namespace FourSlashInterface {
|
||||
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
|
||||
readonly includeInlayFunctionParameterTypeHints?: boolean;
|
||||
readonly includeInlayVariableTypeHints?: boolean;
|
||||
readonly includeInlayVariableTypeHintsWhenTypeMatchesName?: boolean;
|
||||
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
|
||||
readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
|
||||
readonly includeInlayEnumMemberValueHints?: boolean;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// type Client = {};
|
||||
//// function getClient(): Client { return {}; };
|
||||
//// const client/**/ = getClient();
|
||||
|
||||
const markers = test.markers();
|
||||
|
||||
verify.getInlayHints([
|
||||
{
|
||||
text: ': Client',
|
||||
position: markers[0].position,
|
||||
kind: ts.InlayHintKind.Type,
|
||||
whitespaceBefore: true
|
||||
}
|
||||
], undefined, {
|
||||
includeInlayVariableTypeHints: true,
|
||||
includeInlayVariableTypeHintsWhenTypeMatchesName: true
|
||||
});
|
||||
|
||||
verify.getInlayHints([], undefined, {
|
||||
includeInlayVariableTypeHints: true,
|
||||
includeInlayVariableTypeHintsWhenTypeMatchesName: false
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////function a() {
|
||||
//// ty/**/
|
||||
////}
|
||||
|
||||
verify.completions({
|
||||
marker: "",
|
||||
includes: [{ name: "type", sortText: completion.SortText.GlobalsOrKeywords }]
|
||||
});
|
||||
Reference in New Issue
Block a user