<div><p>Hia,
trying to run all the definately typed files x.def.ts thru
C:\A\N\node_modules\tern\bin\from_ts
or more directly just calling ts.translate(txt, name)
and am getting the following error at tern\lib\typescript.js:61:25</p>
<p>var name = identifier.text();
^
TypeError: Cannot call method 'text' of undefined
at addToObj (C:\A\N\node_modules\tern\lib\typescript.js:61:25)
at objType (C:\A\N\node_modules\tern\lib\typescript.js:112:7)
at objType (C:\A\N\node_modules\tern\lib\typescript.js:105:25)
at objType (C:\A\N\node_modules\tern\lib\typescript.js:98:59)
at Object.exports.translate (C:\A\N\node_modules\tern\lib\typescript.js:201:14)
at finish (C:\A\N\node_modules\tern\bin\from_ts:33:33)
at module.exports (C:\A\N\node_modules\tern\bin\from_ts:37:1)
at Object. (C:\A\N\node_modules\ulexite_E_x00x2014x07x23x10.js:2:48)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)</p>
<p>at first it was this bit</p>
<p>// The TypeScript code is all there in the npm package, but it's not
// exporting anything as a CommonJS module, so we use this kludge to
// get at its internals.
var tsFileName = __dirname + "/../node_modules/typescript/bin/typescript.js";
var tsFileName = "C:/A/N/node_modules/typescript/bin/typescript.js"; // the MS one right?
var box = {};
for (var prop in global) box[prop] = global[prop];</p>
<p>But the full path worked ok until line 61
is returning sometimes ,
but mainly ts.translate(txt, name) is blank or the above error</p>
<p>name= path.basename("C:/A/B/2/J1/Ax/62/jx/d.ts") == "d.ts"
can name be anything? what is the importance of this name?
(i have just like d.ts, etc)</p>
<p>line 61 is this bit...</p>
<p>function addToObj(data, identifier, val) {
var known = data[name];
var name = identifier.text(); ----line 61 is here
if (/^".*"$/.test(name)) name = name.slice(1, name.length - 1);
if (known) {<!-- --></p>
<p>i think the kludge works!!! since
tn and ts return...</p>
<p>{ '0': 'None',
'1': 'List',
'2': 'SeparatedList',
'3': 'TriviaList',
'4': 'WhitespaceTrivia',
'5': 'NewLineTrivia',
'6': 'MultiLineCommentTrivia',
'7': 'SingleLineCommentTrivia',
'8': 'SkippedTokenTrivia',
'9': 'FirstToken',
'10': 'EndOfFileToken',
'11': 'IdentifierName',
'12': 'RegularExpressionLiteral',
'13': 'NumericLiteral',
'14': 'StringLiteral',
'15': 'FirstFixedWidth',
'16': 'CaseKeyword',
'17': 'CatchKeyword',
'18': 'ContinueKeyword',
'19': 'DebuggerKeyword',
'20': 'DefaultKeyword',
'21': 'DeleteKeyword',</p>
<p>and ts...</p>
<p>{ DiagnosticCode:
{ error_TS_0_1: 'error TS{0}: {1}',
warning_TS_0_1: 'warning TS{0}: {1}',
Unrecognized_escape_sequence: 'Unrecognized escape sequence.',
Unexpected_character_0: 'Unexpected character {0}.',
Missing_close_quote_character: 'Missing close quote character.',
Identifier_expected: 'Identifier expected.',
_0_keyword_expected: '\'{0}\' keyword expected.',
_0_expected: '\'{0}\' expected.',
Identifier_expected_0_is_a_keyword: 'Identifier expected; \'{0}\' is a keyword.',
Automatic_semicolon_insertion_not_allowed: 'Automatic semicolon insertion not allowed.',
Unexpected_token_0_expected: 'Unexpected token; \'{0}\' expected.',
Trailing_separator_not_allowed: 'Trailing separator not allowed.',
AsteriskSlash_expected: '\'*/\' expected.',
public_or_private_modifier_must_precede_static: '\'public\' or \'private\' modifier must precede \'static\'.',
Unexpected_token: 'Unexpected token.',
Catch_clause_parameter_cannot_have_a_type_annotation: 'Catch clause parameter cannot have a type annotation.',
Rest_parameter_must_be_last_in_list: 'Rest parameter must be last in list.',
Parameter_cannot_have_question_mark_and_initializer: 'Parameter cannot have question mark and initializer.',
Required_parameter_cannot_follow_optional_parameter: 'Required parameter cannot follow optional parameter.',
Index_signatures_cannot_have_rest_parameters: 'Index signatures cannot have rest parameters.',
Index_signature_parameter_cannot_have_accessibility_modifiers: 'Index signature parameter cannot have accessibility modifiers.',
Index_signature_parameter_cannot_have_a_question_mark: 'Index signature parameter cannot have a question mark.',
Index_signature_parameter_cannot_have_an_initializer: 'Index signature parameter cannot have an initializer.',
Index_signature_must_have_a_type_annotation: 'Index signature must have a type annotation.',
Index_signature_parameter_must_have_a_type_annotation: 'Index signature parameter must have a type annotation.',
Index_signature_parameter_type_must_be_string_or_number: 'Index signature parameter type must be \'string\' or \'number\'.',
extends_clause_already_seen: '\'extends\' clause already seen.',
extends_clause_must_precede_implements_clause: '\'extends\' </p><p>该提问来源于开源项目:ternjs/tern</p></div>