On this file
declarevarrequire:any;varHTMLDOMPropertyConfig=require('react/lib/HTMLDOMPropertyConfig');// Populate property map with ReactJS's attribute and property mappings// TODO handle/use .Properties value eg: MUST_USE_PROPERTY is not HTML attrfor(varpropnameinHTMLDOMPropertyConfig.Properties){if(!HTMLDOMPropertyConfig.Properties.hasOwnProperty(propname)){continue;}varmapFrom=HTMLDOMPropertyConfig.DOMAttributeNames[propname]||propname.toLowerCase();}/** * Repeats a string a certain number of times. * Also: the future is bright and consists of native string repetition: * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat * * @param {string} string String to repeat * @param {number} times Number of times to repeat string. Integer. * @see http://jsperf.com/string-repeater/2 */functionrepeatString(string,times){if(times===1){returnstring;}if(times<0){thrownewError();}varrepeated='';while(times){if(times&1){repeated+=string;}if(times>>=1){string+=string;}}returnrepeated;}/** * Determine if the string ends with the specified substring. * * @param {string} haystack String to search in * @param {string} needle String to search for * @return {boolean} */functionendsWith(haystack,needle){returnhaystack.slice(-needle.length)===needle;}/** * Trim the specified substring off the string. If the string does not end * with the specified substring, this is a no-op. * * @param {string} haystack String to search in * @param {string} needle String to search for * @return {string} */functiontrimEnd(haystack,needle){returnendsWith(haystack,needle)
? haystack.slice(0,-needle.length)
: haystack;}/** * Convert a hyphenated string to camelCase. */functionhyphenToCamelCase(string){returnstring.replace(/-(.)/g,function(match,chr){returnchr.toUpperCase();});}/** * Determines if the specified string consists entirely of whitespace. */functionisEmpty(string){return!/[^\s]/.test(string);}/** * Determines if the CSS value can be converted from a * 'px' suffixed string to a numeric value * * @param {string} value CSS property value * @return {boolean} */functionisConvertiblePixelValue(value){return/^\d+px$/.test(value);}exportclassHTMLtoJSX{privateoutput: string;privatelevel: number;private_inPreTag: boolean;/** * Handles processing of the specified text node * * @param {TextNode} node */_visitText=(node)=>{varparentTag=node.parentNode&&node.parentNode.tagName.toLowerCase();if(parentTag==='textarea'||parentTag==='style'){// Ignore text content of textareas and styles, as it will have already been moved// to a "defaultValue" attribute and "dangerouslySetInnerHTML" attribute respectively.return;}vartext=''if(this._inPreTag){// If this text is contained within a <pre>, we need to ensure the JSX// whitespace coalescing rules don't eat the whitespace. This means// wrapping newlines and sequences of two or more spaces in variables.text=text.replace(/\r/g,'').replace(/({2,}|\n|\t|\{|\})/g,function(whitespace){return'{'+JSON.stringify(whitespace)+'}';});}else{// If there's a newline in the text, adjust the indent levelif(text.indexOf('\n')>-1){}}this.output+=text;}};/** * Handles parsing of inline styles */exportclassStyleParser{styles={};toJSXString=()=>{for(varkeyinthis.styles){if(!this.styles.hasOwnProperty(key)){}}}}which is actually a part of a larger file here
With TypeScript nightly we get the following errors:
C:/repos/alm/tests/success/simple/bas.tsx:141 Property 'styles' does not exist on type 'HTMLtoJSX'.
C:/repos/alm/tests/success/simple/bas.tsx:142 Property 'styles' does not exist on type 'HTMLtoJSX'.
Basically this in the class function isn't inferring to StyleParser and instead inferring to HTMLtoJSX
exportclassStyleParser{styles={};toJSXString=()=>{for(varkeyinthis.styles){if(!this.styles.hasOwnProperty(key)){}}}}Sorry for not being able to narrow it down, deleting portions of the file (e.g. the HTMLtoJSX._visitText method) makes the error go away. Note that this error only appeared in the last 10 days 🌹
On this file
With TypeScript nightly we get the following errors:
Basically
thisin the class function isn't inferring toStyleParserand instead inferring toHTMLtoJSXSorry for not being able to narrow it down, deleting portions of the file (e.g. the
HTMLtoJSX._visitTextmethod) makes the error go away. Note that this error only appeared in the last 10 days 🌹