Skip to content

Commit

Permalink
add diagnostics messages 'Method not implemented.' and 'Function not …
Browse files Browse the repository at this point in the history
…implemented.'
  • Loading branch information
a-tarasyuk committed Dec 19, 2020
1 parent d6d18ea commit 127e16e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -5991,6 +5991,14 @@
"category": "Message",
"code": 95150
},
"Method not implemented.": {
"category": "Message",
"code": 95151
},
"Function not implemented.": {
"category": "Message",
"code": 95152
},


"No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer.": {
Expand Down
27 changes: 23 additions & 4 deletions src/services/codefixes/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,29 @@ namespace ts.codefix {
: checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker);

if (kind === SyntaxKind.MethodDeclaration) {
const body = isInterfaceDeclaration(contextNode) ? undefined : createStubbedMethodBody(quotePreference);
return factory.createMethodDeclaration(/*decorators*/ undefined, modifiers, asteriskToken, name, /*questionToken*/ undefined, typeParameters, parameters, type, body) as T;
return factory.createMethodDeclaration(
/*decorators*/ undefined,
modifiers,
asteriskToken,
name,
/*questionToken*/ undefined,
typeParameters,
parameters,
type,
isInterfaceDeclaration(contextNode) ? undefined : createStubbedMethodBody(quotePreference)
) as T;
}
return factory.createFunctionDeclaration(/*decorators*/ undefined, modifiers, asteriskToken, name, typeParameters, parameters, type, createStubbedBody("Function not implemented.", quotePreference)) as T;

return factory.createFunctionDeclaration(
/*decorators*/ undefined,
modifiers,
asteriskToken,
name,
typeParameters,
parameters,
type,
createStubbedBody(Diagnostics.Function_not_implemented.message, quotePreference)
) as T;
}

export function typeToAutoImportableTypeNode(checker: TypeChecker, importAdder: ImportAdder, type: Type, contextNode: Node | undefined, scriptTarget: ScriptTarget, flags?: NodeBuilderFlags, tracker?: SymbolTracker): TypeNode | undefined {
Expand Down Expand Up @@ -392,7 +411,7 @@ namespace ts.codefix {
}

function createStubbedMethodBody(quotePreference: QuotePreference) {
return createStubbedBody("Method not implemented.", quotePreference);
return createStubbedBody(Diagnostics.Method_not_implemented.message, quotePreference);
}

export function createStubbedBody(text: string, quotePreference: QuotePreference): Block {
Expand Down

0 comments on commit 127e16e

Please sign in to comment.