diff --git a/src/services/completions.ts b/src/services/completions.ts index e7e06cb7dfc71..9be6e00716ca3 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -272,7 +272,7 @@ namespace ts.Completions { } for (const literal of literals) { - entries.push(createCompletionEntryForLiteral(literal)); + entries.push(createCompletionEntryForLiteral(literal, preferences)); } return { isGlobalCompletion: isInSnippetScope, isMemberCompletion: isMemberCompletionKind(completionKind), isNewIdentifierLocation, entries }; @@ -317,10 +317,13 @@ namespace ts.Completions { }); } - const completionNameForLiteral = (literal: string | number | PseudoBigInt) => - typeof literal === "object" ? pseudoBigIntToString(literal) + "n" : JSON.stringify(literal); - function createCompletionEntryForLiteral(literal: string | number | PseudoBigInt): CompletionEntry { - return { name: completionNameForLiteral(literal), kind: ScriptElementKind.string, kindModifiers: ScriptElementKindModifier.none, sortText: SortText.LocationPriority }; + function completionNameForLiteral(literal: string | number | PseudoBigInt, preferences: UserPreferences): string { + return typeof literal === "object" ? pseudoBigIntToString(literal) + "n" : + isString(literal) ? quote(literal, preferences) : JSON.stringify(literal); + } + + function createCompletionEntryForLiteral(literal: string | number | PseudoBigInt, preferences: UserPreferences): CompletionEntry { + return { name: completionNameForLiteral(literal, preferences), kind: ScriptElementKind.string, kindModifiers: ScriptElementKindModifier.none, sortText: SortText.LocationPriority }; } function createCompletionEntry( @@ -344,13 +347,13 @@ namespace ts.Completions { const useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess; if (origin && originIsThisType(origin)) { insertText = needsConvertPropertyAccess - ? `this${insertQuestionDot ? "?." : ""}[${quote(name, preferences)}]` + ? `this${insertQuestionDot ? "?." : ""}[${quotePropertyName(name, preferences)}]` : `this${insertQuestionDot ? "?." : "."}${name}`; } // We should only have needsConvertPropertyAccess if there's a property access to convert. But see #21790. // Somehow there was a global with a non-identifier name. Hopefully someone will complain about getting a "foo bar" global completion and provide a repro. else if ((useBraces || insertQuestionDot) && propertyAccessToConvert) { - insertText = useBraces ? needsConvertPropertyAccess ? `[${quote(name, preferences)}]` : `[${name}]` : name; + insertText = useBraces ? needsConvertPropertyAccess ? `[${quotePropertyName(name, preferences)}]` : `[${name}]` : name; if (insertQuestionDot || propertyAccessToConvert.questionDotToken) { insertText = `?.${insertText}`; } @@ -410,6 +413,14 @@ namespace ts.Completions { }; } + function quotePropertyName(name: string, preferences: UserPreferences): string { + if (/^\d+$/.test(name)) { + return name; + } + + return quote(name, preferences); + } + function isRecommendedCompletionMatch(localSymbol: Symbol, recommendedCompletion: Symbol | undefined, checker: TypeChecker): boolean { return localSymbol === recommendedCompletion || !!(localSymbol.flags & SymbolFlags.ExportValue) && checker.getExportSymbolOfSymbol(localSymbol) === recommendedCompletion; @@ -531,6 +542,7 @@ namespace ts.Completions { position: number, entryId: CompletionEntryIdentifier, host: LanguageServiceHost, + preferences: UserPreferences, ): SymbolCompletion | { type: "request", request: Request } | { type: "literal", literal: string | number | PseudoBigInt } | { type: "none" } { const compilerOptions = program.getCompilerOptions(); const completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId, host); @@ -543,7 +555,7 @@ namespace ts.Completions { const { symbols, literals, location, completionKind, symbolToOriginInfoMap, previousToken, isJsxInitializer, isTypeOnlyLocation } = completionData; - const literal = find(literals, l => completionNameForLiteral(l) === entryId.name); + const literal = find(literals, l => completionNameForLiteral(l, preferences) === entryId.name); if (literal !== undefined) return { type: "literal", literal }; // Find the symbol with the matching entry name. @@ -585,7 +597,7 @@ namespace ts.Completions { } // Compute all the completion symbols again. - const symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host); + const symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences); switch (symbolCompletion.type) { case "request": { const { request } = symbolCompletion; @@ -607,7 +619,7 @@ namespace ts.Completions { } case "literal": { const { literal } = symbolCompletion; - return createSimpleDetails(completionNameForLiteral(literal), ScriptElementKind.string, typeof literal === "string" ? SymbolDisplayPartKind.stringLiteral : SymbolDisplayPartKind.numericLiteral); + return createSimpleDetails(completionNameForLiteral(literal, preferences), ScriptElementKind.string, typeof literal === "string" ? SymbolDisplayPartKind.stringLiteral : SymbolDisplayPartKind.numericLiteral); } case "none": // Didn't find a symbol with this name. See if we can find a keyword instead. @@ -677,8 +689,9 @@ namespace ts.Completions { position: number, entryId: CompletionEntryIdentifier, host: LanguageServiceHost, + preferences: UserPreferences, ): Symbol | undefined { - const completion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host); + const completion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences); return completion.type === "symbol" ? completion.symbol : undefined; } diff --git a/src/services/services.ts b/src/services/services.ts index 0c45e3f2d6ba5..1c39dca0488cf 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1490,9 +1490,9 @@ namespace ts { ); } - function getCompletionEntrySymbol(fileName: string, position: number, name: string, source?: string): Symbol | undefined { + function getCompletionEntrySymbol(fileName: string, position: number, name: string, source?: string, preferences: UserPreferences = emptyOptions): Symbol | undefined { synchronizeHostData(); - return Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name, source }, host); + return Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name, source }, host, preferences); } function getQuickInfoAtPosition(fileName: string, position: number): QuickInfo | undefined { diff --git a/src/services/utilities.ts b/src/services/utilities.ts index d94106486446d..b20d79624a536 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -2343,9 +2343,6 @@ namespace ts { } export function quote(text: string, preferences: UserPreferences): string { - if (/^\d+$/.test(text)) { - return text; - } // Editors can pass in undefined or empty string - we want to infer the preference in those cases. const quotePreference = preferences.quotePreference || "auto"; const quoted = JSON.stringify(text); diff --git a/tests/baselines/reference/docker/azure-sdk.log b/tests/baselines/reference/docker/azure-sdk.log index 44df5889d78e8..5391ceedf4718 100644 --- a/tests/baselines/reference/docker/azure-sdk.log +++ b/tests/baselines/reference/docker/azure-sdk.log @@ -2,7 +2,7 @@ Exit Code: 1 Standard output: Rush Multi-Project Build Tool 5.X.X - https://rushjs.io -Node.js version is 12.16.0 (LTS) +Node.js version is 12.16.1 (LTS) Starting "rush rebuild" Executing a maximum of ?simultaneous processes... XX of XX: [@azure/abort-controller] completed successfully in ? seconds @@ -41,7 +41,6 @@ npm ERR! Failed at the @azure/keyvault-certificates@X.X.X extract-api script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/XXXX-XX-XXXXXXXXX-debug.log -Warning: You have changed the public API signature for this project. Updating review/service-bus.api.md npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! @azure/storage-file-datalake@X.X.X-preview.9 build:es6: `tsc -p tsconfig.json && npm run build:types` @@ -75,7 +74,7 @@ SUCCESS (17) @azure/template (? seconds) testhub (? seconds) ================================ -SUCCESS WITH WARNINGS (7) +SUCCESS WITH WARNINGS (6) ================================ @azure/event-hubs (? seconds) Warning: You have changed the public API signature for this project. Updating review/event-hubs.api.md @@ -93,14 +92,12 @@ os-name (imported by dist-esm/utils/user-agent.js) Use output.globals to specify browser global variable names corresponding to external modules os-name (guessing 'osName') created dist/index.js in ?s -@azure/service-bus (? seconds) -Warning: You have changed the public API signature for this project. Updating review/service-bus.api.md @azure/storage-file-share (? seconds) Warning: You have changed the public API signature for this project. Updating review/storage-file-share.api.md @azure/storage-queue (? seconds) Warning: You have changed the public API signature for this project. Updating review/storage-queue.api.md ================================ -FAILURE (4) +FAILURE (5) ================================ @azure/app-configuration ( ? seconds) >>> @azure/app-configuration @@ -123,7 +120,7 @@ test/testHelpers.ts(92,31): error TS2322: Type 'PagedAsyncIterableIterator Promise<{ done?: boolean | undefined; value: ConfigurationSetting; }>' is not assignable to type '(value?: any) => Promise>'. Type 'Promise<{ done?: boolean | undefined; value: ConfigurationSetting; }>' is not assignable to type 'Promise>'. -@azure/eventhubs-checkpointstore-blob ( ? seconds) +@azure/eventhubs-checkpointstore-blob (? seconds) >>> @azure/eventhubs-checkpointstore-blob tsc -p . && rollup -c 2>&1 && npm run extract-api src/blobCheckpointStore.ts(50,32): error TS2322: Type 'PagedAsyncIterableIterator' is not assignable to type 'AsyncIterable'. @@ -137,7 +134,7 @@ src/blobCheckpointStore.ts(50,32): error TS2322: Type 'PagedAsyncIterableIterato Types of property 'done' are incompatible. Type 'boolean | undefined' is not assignable to type 'boolean'. Type 'undefined' is not assignable to type 'boolean'. -@azure/keyvault-certificates ( ? seconds) +@azure/keyvault-certificates (? seconds) npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! @azure/keyvault-certificates@X.X.X extract-api: `tsc -p . && api-extractor run --local` @@ -147,6 +144,15 @@ npm ERR! Failed at the @azure/keyvault-certificates@X.X.X extract-api script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/XXXX-XX-XXXXXXXXX-debug.log +@azure/service-bus (? seconds) +>>> @azure/service-bus +tsc -p . && rollup -c 2>&1 && npm run extract-api +src/serviceBusClient.ts(90,34): error TS1109: Expression expected. +src/serviceBusClient.ts(90,52): error TS1109: Expression expected. +src/serviceBusClient.ts(90,62): error TS1005: ':' expected. +src/serviceBusClient.ts(92,52): error TS1109: Expression expected. +src/serviceBusClient.ts(92,70): error TS1109: Expression expected. +src/serviceBusClient.ts(92,98): error TS1005: ':' expected. @azure/storage-file-datalake (? seconds) npm ERR! code ELIFECYCLE npm ERR! errno 2 @@ -171,11 +177,12 @@ XX of XX: [@azure/app-configuration] failed! XX of XX: [@azure/cosmos] completed with warnings in ? seconds XX of XX: [@azure/eventhubs-checkpointstore-blob] failed! XX of XX: [@azure/keyvault-certificates] failed! -XX of XX: [@azure/service-bus] completed with warnings in ? seconds +XX of XX: [@azure/service-bus] failed! XX of XX: [@azure/storage-file-datalake] failed! XX of XX: [@azure/storage-file-share] completed with warnings in ? seconds XX of XX: [@azure/storage-queue] completed with warnings in ? seconds [@azure/app-configuration] Returned error code: 2 [@azure/eventhubs-checkpointstore-blob] Returned error code: 2 [@azure/keyvault-certificates] Returned error code: 2 +[@azure/service-bus] Returned error code: 2 [@azure/storage-file-datalake] Returned error code: 2 diff --git a/tests/baselines/reference/docker/office-ui-fabric.log b/tests/baselines/reference/docker/office-ui-fabric.log index f592c3c089e6b..642f03d101eef 100644 --- a/tests/baselines/reference/docker/office-ui-fabric.log +++ b/tests/baselines/reference/docker/office-ui-fabric.log @@ -152,10 +152,10 @@ Standard output: @fluentui/local-sandbox: Version: webpack 4.X.X @fluentui/local-sandbox: Time: ?s @fluentui/local-sandbox: Built at: XX/XX/XX XX:XX:XX XM -@fluentui/local-sandbox: Asset Size Chunks Chunk Names -@fluentui/local-sandbox: app.js 4.79 MiB app [emitted] [big] app -@fluentui/local-sandbox: app.js.map 3.86 MiB app [emitted] app -@fluentui/local-sandbox: index.html X KiB [emitted] +@fluentui/local-sandbox: Asset Size Chunks Chunk Names +@fluentui/local-sandbox: app.js 4.82 MiB app [emitted] [big] app +@fluentui/local-sandbox: app.js.map 3.89 MiB app [emitted] [dev] app +@fluentui/local-sandbox: index.html X KiB [emitted] @fluentui/local-sandbox: Entrypoint app [big] = app.js app.js.map @fluentui/local-sandbox: [../accessibility/dist/es/index.js] X KiB {app} [built] @fluentui/local-sandbox: [../react-bindings/dist/es/index.js] X KiB {app} [built] @@ -172,7 +172,7 @@ Standard output: @fluentui/local-sandbox: [../react/dist/es/utils/positioner/types.js] X KiB {app} [built] @fluentui/local-sandbox: [../styles/dist/es/index.js] X KiB {app} [built] @fluentui/local-sandbox: [./src/index.tsx] X KiB {app} [built] -@fluentui/local-sandbox: + 1208 hidden modules +@fluentui/local-sandbox: + 1223 hidden modules @fluentui/local-sandbox: Done in ?s. @uifabric/utilities: yarn run vX.X.X @uifabric/utilities: $ just-scripts build @@ -183,15 +183,6 @@ Standard output: @uifabric/utilities: [XX:XX:XX XM] ■ Executing: /usr/local/bin/node "/office-ui-fabric-react/node_modules/typescript/lib/tsc.js" --pretty --target es5 --outDir lib --module esnext --project "/office-ui-fabric-react/packages/utilities/tsconfig.json" @uifabric/utilities: [XX:XX:XX XM] ■ Extracting Public API surface from '/office-ui-fabric-react/packages/utilities/lib/index.d.ts' @uifabric/utilities: Done in ?s. -@fluentui/react-focus: yarn run vX.X.X -@fluentui/react-focus: $ just-scripts build -@fluentui/react-focus: [XX:XX:XX XM] ■ Removing [lib, temp, dist, lib-amd, lib-commonjs, lib-es2015, coverage, src/**/*.scss.ts] -@fluentui/react-focus: [XX:XX:XX XM] ■ Running /office-ui-fabric-react/node_modules/typescript/lib/tsc.js with /office-ui-fabric-react/packages/react-focus/tsconfig.json -@fluentui/react-focus: [XX:XX:XX XM] ■ Executing: /usr/local/bin/node "/office-ui-fabric-react/node_modules/typescript/lib/tsc.js" --pretty --target es5 --outDir lib-commonjs --module commonjs --project "/office-ui-fabric-react/packages/react-focus/tsconfig.json" -@fluentui/react-focus: [XX:XX:XX XM] ■ Running /office-ui-fabric-react/node_modules/typescript/lib/tsc.js with /office-ui-fabric-react/packages/react-focus/tsconfig.json -@fluentui/react-focus: [XX:XX:XX XM] ■ Executing: /usr/local/bin/node "/office-ui-fabric-react/node_modules/typescript/lib/tsc.js" --pretty --target es5 --outDir lib --module esnext --project "/office-ui-fabric-react/packages/react-focus/tsconfig.json" -@fluentui/react-focus: [XX:XX:XX XM] ■ Extracting Public API surface from '/office-ui-fabric-react/packages/react-focus/lib/index.d.ts' -@fluentui/react-focus: Done in ?s. @uifabric/react-hooks: yarn run vX.X.X @uifabric/react-hooks: $ just-scripts build @uifabric/react-hooks: [XX:XX:XX XM] ■ Removing [lib, temp, dist, lib-amd, lib-commonjs, lib-es2015, coverage, src/**/*.scss.ts] @@ -245,6 +236,15 @@ Standard output: @uifabric/icons: [XX:XX:XX XM] ■ Executing: /usr/local/bin/node "/office-ui-fabric-react/node_modules/typescript/lib/tsc.js" --pretty --target es5 --outDir lib --module esnext --project "/office-ui-fabric-react/packages/icons/tsconfig.json" @uifabric/icons: [XX:XX:XX XM] ■ Extracting Public API surface from '/office-ui-fabric-react/packages/icons/lib/index.d.ts' @uifabric/icons: Done in ?s. +@fluentui/react-focus: yarn run vX.X.X +@fluentui/react-focus: $ just-scripts build +@fluentui/react-focus: [XX:XX:XX XM] ■ Removing [lib, temp, dist, lib-amd, lib-commonjs, lib-es2015, coverage, src/**/*.scss.ts] +@fluentui/react-focus: [XX:XX:XX XM] ■ Running /office-ui-fabric-react/node_modules/typescript/lib/tsc.js with /office-ui-fabric-react/packages/react-focus/tsconfig.json +@fluentui/react-focus: [XX:XX:XX XM] ■ Executing: /usr/local/bin/node "/office-ui-fabric-react/node_modules/typescript/lib/tsc.js" --pretty --target es5 --outDir lib-commonjs --module commonjs --project "/office-ui-fabric-react/packages/react-focus/tsconfig.json" +@fluentui/react-focus: [XX:XX:XX XM] ■ Running /office-ui-fabric-react/node_modules/typescript/lib/tsc.js with /office-ui-fabric-react/packages/react-focus/tsconfig.json +@fluentui/react-focus: [XX:XX:XX XM] ■ Executing: /usr/local/bin/node "/office-ui-fabric-react/node_modules/typescript/lib/tsc.js" --pretty --target es5 --outDir lib --module esnext --project "/office-ui-fabric-react/packages/react-focus/tsconfig.json" +@fluentui/react-focus: [XX:XX:XX XM] ■ Extracting Public API surface from '/office-ui-fabric-react/packages/react-focus/lib/index.d.ts' +@fluentui/react-focus: Done in ?s. @fluentui/playground: yarn run vX.X.X @fluentui/playground: $ just-scripts build @fluentui/playground: [XX:XX:XX XM] ■ Removing [lib, temp, dist, lib-amd, lib-commonjs, lib-es2015, coverage, src/**/*.scss.ts] @@ -270,27 +270,27 @@ Standard error: info cli using local version of lerna lerna notice cli vX.X.X lerna info Executing command in 61 packages: "yarn run build" -@fluentui/ability-attributes: npm WARN lifecycle The node binary used for scripts is /tmp/yarn--1581721799113-0.08545685427418936/node but npm is using /usr/local/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with. +@fluentui/ability-attributes: npm WARN lifecycle The node binary used for scripts is /tmp/yarn--1582217617919-0.14533570754354042/node but npm is using /usr/local/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with. @uifabric/example-data: [XX:XX:XX XM] ▲ One of these [node-sass, postcss, autoprefixer] is not installed, so this task has no effect @uifabric/set-version: [XX:XX:XX XM] ▲ One of these [node-sass, postcss, autoprefixer] is not installed, so this task has no effect @uifabric/merge-styles: [XX:XX:XX XM] ▲ One of these [node-sass, postcss, autoprefixer] is not installed, so this task has no effect @uifabric/jest-serializer-merge-styles: [XX:XX:XX XM] ▲ One of these [node-sass, postcss, autoprefixer] is not installed, so this task has no effect @fluentui/react: (node:1020) [DEP0097] DeprecationWarning: Using a domain property in MakeCallback is deprecated. Use the async_context variant of MakeCallback or the AsyncResource class instead. @uifabric/utilities: [XX:XX:XX XM] ▲ One of these [node-sass, postcss, autoprefixer] is not installed, so this task has no effect -@fluentui/react-focus: [XX:XX:XX XM] ▲ One of these [node-sass, postcss, autoprefixer] is not installed, so this task has no effect @uifabric/react-hooks: [XX:XX:XX XM] ▲ One of these [node-sass, postcss, autoprefixer] is not installed, so this task has no effect @uifabric/styling: [XX:XX:XX XM] ▲ One of these [node-sass, postcss, autoprefixer] is not installed, so this task has no effect @fluentui/react-theming: [XX:XX:XX XM] ▲ One of these [node-sass, postcss, autoprefixer] is not installed, so this task has no effect @uifabric/file-type-icons: [XX:XX:XX XM] ▲ One of these [node-sass, postcss, autoprefixer] is not installed, so this task has no effect @uifabric/foundation: [XX:XX:XX XM] ▲ One of these [node-sass, postcss, autoprefixer] is not installed, so this task has no effect @uifabric/icons: [XX:XX:XX XM] ▲ One of these [node-sass, postcss, autoprefixer] is not installed, so this task has no effect +@fluentui/react-focus: [XX:XX:XX XM] ▲ One of these [node-sass, postcss, autoprefixer] is not installed, so this task has no effect @fluentui/playground: [XX:XX:XX XM] ▲ One of these [node-sass, postcss, autoprefixer] is not installed, so this task has no effect office-ui-fabric-react: [XX:XX:XX XM] ▲ One of these [node-sass, postcss, autoprefixer] is not installed, so this task has no effect office-ui-fabric-react: [XX:XX:XX XM] x Error detected while running 'ts:esm' office-ui-fabric-react: [XX:XX:XX XM] x ------------------------------------ office-ui-fabric-react: [XX:XX:XX XM] x Error: Command failed: /usr/local/bin/node "/office-ui-fabric-react/node_modules/typescript/lib/tsc.js" --pretty --target es5 --outDir lib --module esnext --project "/office-ui-fabric-react/packages/office-ui-fabric-react/tsconfig.json" office-ui-fabric-react: at ChildProcess.exithandler (child_process.js:303:12) -office-ui-fabric-react: at ChildProcess.emit (events.js:321:20) +office-ui-fabric-react: at ChildProcess.emit (events.js:311:20) office-ui-fabric-react: at ChildProcess.EventEmitter.emit (domain.js:505:15) office-ui-fabric-react: at maybeClose (internal/child_process.js:1021:16) office-ui-fabric-react: at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) @@ -319,8 +319,8 @@ office-ui-fabric-react: ~~~~~~~~~~~~~~~~~~~~~~~ office-ui-fabric-react: src/components/ContextualMenu/examples/ContextualMenu.Icon.Example.tsx:12:31 - error TS2307: Cannot find module './ContextualMenuExample.scss'. office-ui-fabric-react: 12 import * as stylesImport from './ContextualMenuExample.scss'; office-ui-fabric-react: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -office-ui-fabric-react: src/components/DetailsList/DetailsList.base.tsx:479:19 - error TS2783: 'selection' is specified more than once, so this usage will be overwritten. -office-ui-fabric-react: 479 selection={selection} +office-ui-fabric-react: src/components/DetailsList/DetailsList.base.tsx:480:19 - error TS2783: 'selection' is specified more than once, so this usage will be overwritten. +office-ui-fabric-react: 480 selection={selection} office-ui-fabric-react: ~~~~~~~~~~~~~~~~~~~~~ office-ui-fabric-react: src/components/ExtendedPicker/BaseExtendedPicker.tsx:5:31 - error TS2307: Cannot find module './BaseExtendedPicker.scss'. office-ui-fabric-react: 5 import * as stylesImport from './BaseExtendedPicker.scss'; diff --git a/tests/baselines/reference/docker/vscode.log b/tests/baselines/reference/docker/vscode.log index 7484c083d8cb9..2317e17eb3077 100644 --- a/tests/baselines/reference/docker/vscode.log +++ b/tests/baselines/reference/docker/vscode.log @@ -4,7 +4,7 @@ yarn run vX.X.X $ gulp compile --max_old_space_size=4095 [XX:XX:XX] Node flags detected: --max_old_space_size=4095 [XX:XX:XX] Using gulpfile /vscode/gulpfile.js -[XX:XX:XX] Error: /vscode/extensions/typescript-language-features/src/typescriptServiceClient.ts(735,37): 'command' is specified more than once, so this usage will be overwritten. +[XX:XX:XX] Error: /vscode/extensions/typescript-language-features/src/typescriptServiceClient.ts(734,37): 'command' is specified more than once, so this usage will be overwritten. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. diff --git a/tests/baselines/reference/user/uglify-js.log b/tests/baselines/reference/user/uglify-js.log index ba84268829962..c1b96a8130b81 100644 --- a/tests/baselines/reference/user/uglify-js.log +++ b/tests/baselines/reference/user/uglify-js.log @@ -1,14 +1,14 @@ Exit Code: 1 Standard output: -node_modules/uglify-js/lib/ast.js(223,38): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/ast.js(902,5): error TS2322: Type '{ _visit: (node: any, descend: any) => any; parent: (n: any) => any; push: typeof push; pop: typeof pop; self: () => any; find_parent: (type: any) => any; has_directive: (type: any) => any; loopcontrol_target: (node: any) => any; in_boolean_context: () => boolean | undefined; }' is not assignable to type 'TreeWalker'. +node_modules/uglify-js/lib/ast.js(220,38): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/ast.js(899,5): error TS2322: Type '{ _visit: (node: any, descend: any) => any; parent: (n: any) => any; push: typeof push; pop: typeof pop; self: () => any; find_parent: (type: any) => any; has_directive: (type: any) => any; loopcontrol_target: (node: any) => any; in_boolean_context: () => boolean | undefined; }' is not assignable to type 'TreeWalker'. Object literal may only specify known properties, but '_visit' does not exist in type 'TreeWalker'. Did you mean to write 'visit'? -node_modules/uglify-js/lib/ast.js(903,14): error TS2339: Property 'push' does not exist on type 'TreeWalker'. -node_modules/uglify-js/lib/ast.js(910,14): error TS2339: Property 'pop' does not exist on type 'TreeWalker'. -node_modules/uglify-js/lib/ast.js(965,25): error TS2339: Property 'self' does not exist on type 'TreeWalker'. -node_modules/uglify-js/lib/ast.js(966,37): error TS2339: Property 'parent' does not exist on type 'TreeWalker'. -node_modules/uglify-js/lib/ast.js(984,31): error TS2339: Property 'parent' does not exist on type 'TreeWalker'. -node_modules/uglify-js/lib/ast.js(988,29): error TS2339: Property 'parent' does not exist on type 'TreeWalker'. +node_modules/uglify-js/lib/ast.js(900,14): error TS2339: Property 'push' does not exist on type 'TreeWalker'. +node_modules/uglify-js/lib/ast.js(907,14): error TS2339: Property 'pop' does not exist on type 'TreeWalker'. +node_modules/uglify-js/lib/ast.js(962,25): error TS2339: Property 'self' does not exist on type 'TreeWalker'. +node_modules/uglify-js/lib/ast.js(963,37): error TS2339: Property 'parent' does not exist on type 'TreeWalker'. +node_modules/uglify-js/lib/ast.js(981,31): error TS2339: Property 'parent' does not exist on type 'TreeWalker'. +node_modules/uglify-js/lib/ast.js(985,29): error TS2339: Property 'parent' does not exist on type 'TreeWalker'. node_modules/uglify-js/lib/compress.js(188,42): error TS2554: Expected 0 arguments, but got 1. node_modules/uglify-js/lib/compress.js(536,41): error TS2554: Expected 0 arguments, but got 1. node_modules/uglify-js/lib/compress.js(876,33): error TS2554: Expected 0 arguments, but got 1. @@ -42,62 +42,61 @@ node_modules/uglify-js/lib/compress.js(2279,59): error TS2554: Expected 0 argume node_modules/uglify-js/lib/compress.js(2317,53): error TS2345: Argument of type 'any[]' is not assignable to parameter of type '[number, number, ...never[]]'. Type 'any[]' is missing the following properties from type '[number, number, ...never[]]': 0, 1 node_modules/uglify-js/lib/compress.js(2465,34): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3234,55): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. -node_modules/uglify-js/lib/compress.js(3235,25): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/compress.js(3235,55): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. -node_modules/uglify-js/lib/compress.js(3235,56): error TS2531: Object is possibly 'null'. -node_modules/uglify-js/lib/compress.js(3276,42): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3355,33): error TS2532: Object is possibly 'undefined'. -node_modules/uglify-js/lib/compress.js(3762,38): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3788,29): error TS2322: Type '"f"' is not assignable to type 'boolean'. -node_modules/uglify-js/lib/compress.js(3921,33): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3922,74): error TS2339: Property 'has_directive' does not exist on type 'TreeWalker'. -node_modules/uglify-js/lib/compress.js(3974,29): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(3992,29): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(4107,63): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(4237,12): error TS2339: Property 'push' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(4333,38): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(4354,24): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(4364,28): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(4449,32): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(4688,17): error TS2447: The '|=' operator is not allowed for boolean types. Consider using '||' instead. -node_modules/uglify-js/lib/compress.js(4756,45): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(4867,33): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(4869,55): error TS2339: Property 'loopcontrol_target' does not exist on type 'TreeWalker'. -node_modules/uglify-js/lib/compress.js(4873,56): error TS2339: Property 'push' does not exist on type 'TreeWalker'. -node_modules/uglify-js/lib/compress.js(4874,12): error TS2339: Property 'push' does not exist on type 'TreeWalker'. -node_modules/uglify-js/lib/compress.js(4959,21): error TS2403: Subsequent variable declarations must have the same type. Variable 'body' must be of type 'any[]', but here has type 'any'. -node_modules/uglify-js/lib/compress.js(4974,21): error TS2403: Subsequent variable declarations must have the same type. Variable 'body' must be of type 'any[]', but here has type 'any'. -node_modules/uglify-js/lib/compress.js(5085,33): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(5087,33): error TS2339: Property 'parent' does not exist on type 'TreeWalker'. -node_modules/uglify-js/lib/compress.js(5235,17): error TS2403: Subsequent variable declarations must have the same type. Variable 'body' must be of type 'any[]', but here has type 'any'. -node_modules/uglify-js/lib/compress.js(5328,37): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(5584,57): error TS2345: Argument of type 'any[]' is not assignable to parameter of type '[string | RegExp, (string | undefined)?]'. +node_modules/uglify-js/lib/compress.js(3252,55): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +node_modules/uglify-js/lib/compress.js(3253,25): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/compress.js(3253,55): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. +node_modules/uglify-js/lib/compress.js(3253,56): error TS2531: Object is possibly 'null'. +node_modules/uglify-js/lib/compress.js(3294,42): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3373,33): error TS2532: Object is possibly 'undefined'. +node_modules/uglify-js/lib/compress.js(3780,38): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3806,29): error TS2322: Type '"f"' is not assignable to type 'boolean'. +node_modules/uglify-js/lib/compress.js(3939,33): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(3940,74): error TS2339: Property 'has_directive' does not exist on type 'TreeWalker'. +node_modules/uglify-js/lib/compress.js(3992,29): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(4012,29): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(4129,63): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(4259,12): error TS2339: Property 'push' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(4358,38): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(4379,24): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(4389,28): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(4474,32): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(4713,17): error TS2447: The '|=' operator is not allowed for boolean types. Consider using '||' instead. +node_modules/uglify-js/lib/compress.js(4888,33): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(4890,55): error TS2339: Property 'loopcontrol_target' does not exist on type 'TreeWalker'. +node_modules/uglify-js/lib/compress.js(4894,56): error TS2339: Property 'push' does not exist on type 'TreeWalker'. +node_modules/uglify-js/lib/compress.js(4895,12): error TS2339: Property 'push' does not exist on type 'TreeWalker'. +node_modules/uglify-js/lib/compress.js(4980,21): error TS2403: Subsequent variable declarations must have the same type. Variable 'body' must be of type 'any[]', but here has type 'any'. +node_modules/uglify-js/lib/compress.js(4995,21): error TS2403: Subsequent variable declarations must have the same type. Variable 'body' must be of type 'any[]', but here has type 'any'. +node_modules/uglify-js/lib/compress.js(5104,33): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(5106,33): error TS2339: Property 'parent' does not exist on type 'TreeWalker'. +node_modules/uglify-js/lib/compress.js(5254,17): error TS2403: Subsequent variable declarations must have the same type. Variable 'body' must be of type 'any[]', but here has type 'any'. +node_modules/uglify-js/lib/compress.js(5347,37): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(5603,57): error TS2345: Argument of type 'any[]' is not assignable to parameter of type '[string | RegExp, (string | undefined)?]'. Property '0' is missing in type 'any[]' but required in type '[string | RegExp, (string | undefined)?]'. -node_modules/uglify-js/lib/compress.js(5748,45): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(5755,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'code' must be of type 'string', but here has type '{ get: () => string; toString: () => string; indent: (half: any) => void; indentation: () => number; current_width: () => number; should_break: () => boolean; has_parens: () => boolean; newline: () => void; print: (str: any) => void; ... 23 more ...; parent: (n: any) => any; }'. -node_modules/uglify-js/lib/compress.js(5759,36): error TS2532: Object is possibly 'undefined'. -node_modules/uglify-js/lib/compress.js(5764,41): error TS2339: Property 'get' does not exist on type 'string'. -node_modules/uglify-js/lib/compress.js(6279,18): error TS2454: Variable 'is_strict_comparison' is used before being assigned. -node_modules/uglify-js/lib/compress.js(6903,29): error TS2367: This condition will always return 'false' since the types 'boolean' and 'string' have no overlap. -node_modules/uglify-js/lib/compress.js(6945,47): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(7026,39): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(7098,39): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(7104,41): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(7107,41): error TS2339: Property 'parent' does not exist on type 'TreeWalker'. -node_modules/uglify-js/lib/compress.js(7665,43): error TS2454: Variable 'property' is used before being assigned. -node_modules/uglify-js/lib/compress.js(7680,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'value' must be of type 'number', but here has type 'any'. -node_modules/uglify-js/lib/compress.js(7683,46): error TS2339: Property 'has_side_effects' does not exist on type 'number'. -node_modules/uglify-js/lib/compress.js(7689,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'value' must be of type 'number', but here has type 'any'. -node_modules/uglify-js/lib/compress.js(7722,34): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(5767,45): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(5774,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'code' must be of type 'string', but here has type '{ get: () => string; toString: () => string; indent: (half: any) => void; indentation: () => number; current_width: () => number; should_break: () => boolean; has_parens: () => boolean; newline: () => void; print: (str: any) => void; ... 23 more ...; parent: (n: any) => any; }'. +node_modules/uglify-js/lib/compress.js(5778,36): error TS2532: Object is possibly 'undefined'. +node_modules/uglify-js/lib/compress.js(5783,41): error TS2339: Property 'get' does not exist on type 'string'. +node_modules/uglify-js/lib/compress.js(6311,18): error TS2454: Variable 'is_strict_comparison' is used before being assigned. +node_modules/uglify-js/lib/compress.js(6935,29): error TS2367: This condition will always return 'false' since the types 'boolean' and 'string' have no overlap. +node_modules/uglify-js/lib/compress.js(6977,47): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(7058,39): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(7130,39): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(7136,41): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(7139,41): error TS2339: Property 'parent' does not exist on type 'TreeWalker'. +node_modules/uglify-js/lib/compress.js(7701,43): error TS2454: Variable 'property' is used before being assigned. +node_modules/uglify-js/lib/compress.js(7716,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'value' must be of type 'number', but here has type 'any'. +node_modules/uglify-js/lib/compress.js(7719,46): error TS2339: Property 'has_side_effects' does not exist on type 'number'. +node_modules/uglify-js/lib/compress.js(7725,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'value' must be of type 'number', but here has type 'any'. +node_modules/uglify-js/lib/compress.js(7758,34): error TS2554: Expected 0 arguments, but got 1. node_modules/uglify-js/lib/minify.js(186,75): error TS2339: Property 'compress' does not exist on type 'Compressor'. node_modules/uglify-js/lib/mozilla-ast.js(566,33): error TS2554: Expected 0 arguments, but got 1. node_modules/uglify-js/lib/output.js(459,37): error TS2554: Expected 0 arguments, but got 1. node_modules/uglify-js/lib/output.js(460,33): error TS2339: Property 'parent' does not exist on type 'TreeWalker'. node_modules/uglify-js/lib/output.js(475,16): error TS2339: Property 'push' does not exist on type 'TreeWalker'. node_modules/uglify-js/lib/output.js(749,38): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/output.js(1151,44): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/output.js(1433,58): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. +node_modules/uglify-js/lib/output.js(1153,44): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/output.js(1442,58): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. node_modules/uglify-js/lib/parse.js(354,20): error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'. Type 'undefined' is not assignable to type 'number'. node_modules/uglify-js/lib/parse.js(433,32): error TS2345: Argument of type 'any' is not assignable to parameter of type 'never'. diff --git a/tests/cases/fourslash/completionForStringLiteral_quotePreference.ts b/tests/cases/fourslash/completionForStringLiteral_quotePreference.ts new file mode 100644 index 0000000000000..62d2fef2a751e --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteral_quotePreference.ts @@ -0,0 +1,25 @@ +/// + +////enum A { +//// A, +//// B, +//// C +////} +////interface B { +//// a: keyof typeof A; +////} +////const b: B = { +//// a: /**/ +////} + +verify.completions({ + marker: "", + includes: [ + { name: "'A'" }, + { name: "'B'" }, + { name: "'C'" }, + ], + preferences: { + quotePreference: 'single', + }, +}); diff --git a/tests/cases/fourslash/completionForStringLiteral_quotePreference1.ts b/tests/cases/fourslash/completionForStringLiteral_quotePreference1.ts new file mode 100644 index 0000000000000..7f244f5d1670b --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteral_quotePreference1.ts @@ -0,0 +1,23 @@ +/// + +////enum A { +//// A, +//// B, +//// C +////} +////interface B { +//// a: keyof typeof A; +////} +////const b: B = { +//// a: /**/ +////} + +verify.completions({ + marker: "", + includes: [ + { name: '"A"' }, + { name: '"B"' }, + { name: '"C"' }, + ], + preferences: { quotePreference: "double" }, +}); diff --git a/tests/cases/fourslash/completionForStringLiteral_quotePreference2.ts b/tests/cases/fourslash/completionForStringLiteral_quotePreference2.ts new file mode 100644 index 0000000000000..f81afc56f417c --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteral_quotePreference2.ts @@ -0,0 +1,17 @@ +/// + +////const a = { +//// '#': 'a' +////}; +////a[|./**/|] + +verify.completions({ + marker: "", + includes: [ + { name: "#", insertText: "['#']", replacementSpan: test.ranges()[0] }, + ], + preferences: { + includeInsertTextCompletions: true, + quotePreference: "single", + }, +}); diff --git a/tests/cases/fourslash/completionForStringLiteral_quotePreference3.ts b/tests/cases/fourslash/completionForStringLiteral_quotePreference3.ts new file mode 100644 index 0000000000000..1045a03fcb02e --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteral_quotePreference3.ts @@ -0,0 +1,17 @@ +/// + +////const a = { +//// "#": "a" +////}; +////a[|./**/|] + +verify.completions({ + marker: "", + includes: [ + { name: "#", insertText: '["#"]', replacementSpan: test.ranges()[0] }, + ], + preferences: { + includeInsertTextCompletions: true, + quotePreference: "double" + }, +}); diff --git a/tests/cases/fourslash/completionForStringLiteral_quotePreference4.ts b/tests/cases/fourslash/completionForStringLiteral_quotePreference4.ts new file mode 100644 index 0000000000000..300720b8d06c5 --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteral_quotePreference4.ts @@ -0,0 +1,13 @@ +/// + +////type T = 0 | 1; +////const t: T = /**/ + +verify.completions({ + marker: "", + includes: [ + { name: "0" }, + { name: "1" }, + ], + isNewIdentifierLocation: true +}); diff --git a/tests/cases/fourslash/completionForStringLiteral_quotePreference5.ts b/tests/cases/fourslash/completionForStringLiteral_quotePreference5.ts new file mode 100644 index 0000000000000..455ac73bb7711 --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteral_quotePreference5.ts @@ -0,0 +1,14 @@ +/// + +////type T = "0" | "1"; +////const t: T = /**/ + +verify.completions({ + marker: "", + includes: [ + { name: "'1'" }, + { name: "'0'" }, + ], + isNewIdentifierLocation: true, + preferences: { quotePreference: "single" } +}); diff --git a/tests/cases/fourslash/completionForStringLiteral_quotePreference6.ts b/tests/cases/fourslash/completionForStringLiteral_quotePreference6.ts new file mode 100644 index 0000000000000..c54445faa2b64 --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteral_quotePreference6.ts @@ -0,0 +1,14 @@ +/// + +////type T = "0" | "1"; +////const t: T = /**/ + +verify.completions({ + marker: "", + includes: [ + { name: '"1"' }, + { name: '"0"' }, + ], + isNewIdentifierLocation: true, + preferences: { quotePreference: "double" } +});